library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.2.0     ✔ readr     2.1.6
## ✔ forcats   1.0.1     ✔ stringr   1.6.0
## ✔ ggplot2   4.0.2     ✔ tibble    3.3.1
## ✔ lubridate 1.9.5     ✔ tidyr     1.3.2
## ✔ purrr     1.2.1     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(gtsummary)
library(tidyr)
library(sjlabelled)
## 
## Adjuntando el paquete: 'sjlabelled'
## 
## The following object is masked from 'package:forcats':
## 
##     as_factor
## 
## The following object is masked from 'package:dplyr':
## 
##     as_label
## 
## The following object is masked from 'package:ggplot2':
## 
##     as_label
library(here)
## here() starts at C:/Users/chegu/Documents/R/ukr-hcws-violence
library(patchwork)
library(ggh4x)

Prepare information

ds <- readRDS("data/ukr_data.rds")  

cb <- read.csv("ext/data_mapping.csv")

# source("src/viridis_noyellow.R")

variable_labels <- # labels for survey data variables
  
  readxl::read_xlsx("ext/var_labels.xlsx")

source("src/functions.R")
## Cargando paquete requerido: Matrix
## 
## Adjuntando el paquete: 'Matrix'
## The following objects are masked from 'package:tidyr':
## 
##     expand, pack, unpack
## Cargando paquete requerido: grid
## Cargando paquete requerido: survival
## 
## Adjuntando el paquete: 'survey'
## The following object is masked from 'package:graphics':
## 
##     dotchart
## Welcome to emmeans.
## Caution: You lose important information if you filter this package's results.
## See '? untidy'
## Cargando paquete requerido: Rcpp
## Loading 'brms' package (version 2.23.0). Useful instructions
## can be found by typing help('brms'). A more detailed introduction
## to the package is available through vignette('brms_overview').
## 
## Adjuntando el paquete: 'brms'
## The following object is masked from 'package:survival':
## 
##     kidney
## The following object is masked from 'package:lme4':
## 
##     ngrps
## The following object is masked from 'package:stats':
## 
##     ar
## 
## Adjuntando el paquete: 'tidybayes'
## The following objects are masked from 'package:brms':
## 
##     dstudent_t, pstudent_t, qstudent_t, rstudent_t
## Cargando paquete requerido: zoo
## 
## Adjuntando el paquete: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
##  cobalt (Version 4.6.2, Build Date: 2026-01-29)
## This is cmdstanr version 0.9.0
## - CmdStanR documentation and vignettes: mc-stan.org/cmdstanr
## - CmdStan path: C:/Users/chegu/.cmdstan/cmdstan-2.38.0
## - CmdStan version: 2.38.0
## This is posterior version 1.6.1.9000
## 
## Adjuntando el paquete: 'posterior'
## The following objects are masked from 'package:stats':
## 
##     mad, sd, var
## The following objects are masked from 'package:base':
## 
##     %in%, match

Ukraine conflict singularities

ua_reg_conflict <- 
  readxl::read_excel("ext/ukr_conflict_reg.xlsx") |>
  mutate(occupation = str_to_title(occupation, locale = "en"),
         combat = str_to_title(combat, locale = "en")) |> 
  mutate(occupation = factor(occupation, levels = c("Yes",
                                                       "Partial",
                                                       "No")),
         combat = factor(combat, levels = c("Yes", "No")),
         loc_3 = as_factor(str_trim(loc_3)),
         loc_en = as_factor(loc_en)
  )

# Add to ds

ds_ua <- 
  ds |>  
  left_join(ua_reg_conflict, by = "loc_3") |> 
  filter(occupation != "Yes")

ds_ua <- 
  ds_ua |> 
  mutate(conflict = if_else(
    occupation == "No" & combat == "No",
    "No conflict zone",
    "Conflict zone"
    ),
    conflict = factor(conflict,
                      levels = c("No conflict zone", 
                                 "Conflict zone"), 
                      ordered = FALSE),
    situation = case_when(
      occupation == "Partial" ~ "Partially occupied",
      combat == "Yes" ~ "Actively in combat",
      TRUE ~ "No conflict area"
    ),
    situation = factor(situation, levels = c("No conflict area",
                                             "Partially occupied",
                                             "Actively in combat"),
                       ordered = FALSE))

Manage variables

ds_ua <- 
  
  ds_ua |> 
  mutate(work_5_rec = fct_collapse(
    work_5,
    "Emergencies" = c("Emergency care outside hospital (e.g., ambulance)",
                      "Emergency department"),
    "In-hospital care" = "Inpatient care (hospital services)",
    "Outpatient care" = c("Primary care (outpatient services)", 
                          "Secondary care (outpatient services)",
                          "Other")),
    work_5_rec = factor(work_5_rec, levels = c("Outpatient care",
                                               "In-hospital care",
                                               "Emergencies"),
                        ordered = FALSE)
    )


ds_ua <- 
  
  ds_ua |> 
  mutate(work_3_rec = fct_collapse(
    work_3,
    "5 years or less" = c("Less than 1 year", "1-3 years", "4-5 years"),
    "More than 10 years" = c("11-20 years", "21-30 years", "31-40 years",
                             "More than 40 years")
  ))


ds_ua <- 
  
  ds_ua |> 
  mutate(scdm_1_rec = fct_collapse(
    scdm_1,
    "20-30" = c("20-25", "26-30"),
    "31-45" = c("31-35", "36-40", "41-45"),
    "46-55" = c("46-50", "51-55"),
    "Over 55" = c("56-60", "61-65", "66-70", "Over 70")
  ))
# EXP Sociodemographic

exp_scdm <- c("scdm_4", "scdm_5", "scdm_6")
exp_scdm_dic <- paste0(exp_scdm, "_dic")

# EXP Occupational

exp_work <- c("work_5", "work_16")
exp_work_dic <- paste0(exp_work, "_dic")

# EXP Violence

exp_vio <- c("work_30", "work_31", "work_32", "work_33")
exp_vio_dic <- paste0(exp_vio, "_dic")

# EXP protective factors

exp_supp <- c("work_21", "work_22", "wb_wami_1", "wb_wami_2")
exp_supp_dic <- paste0(exp_supp, "_dic")

# add to dataset

ds_ua <- 
  
  ds_ua |> 
  
  # recode marital status
  
  mutate(
    scdm_4_dic = fct_collapse(scdm_4,
                              "No partner" = c("Divorced",
                                               "Separated",
                                               "Single",
                                               "Widowed"),
                              "Has a partner" = c("Married",
                                                  "Registered partnership")),
    scdm_4_dic = factor(scdm_4_dic, 
                        levels = c("No partner", "Has a partner"),
                        ordered = FALSE)
  ) |> 
  
  # recode children in household
  
  mutate(
    scdm_5_dic = case_when(
      str_detect(scdm_5, "with children") ~ "Has children",
      str_detect(scdm_5, "without children") ~ "No children",
    TRUE ~ NA),
    scdm_5_dic = factor(scdm_5_dic, 
                        levels = c("Has children", "No children"),
                        ordered = FALSE)
  ) |> 
  
  # recode making ends meet
  
  mutate(
    scdm_6_dic = case_when(
      str_detect(scdm_6, "difficulty") ~ "Difficultly",
      str_detect(scdm_6, "easily") ~ "Easily",
    TRUE ~ NA),
    scdm_6_dic = factor(scdm_6_dic, 
                        levels = c("Difficultly", "Easily"),
                        ordered = FALSE)
  ) |> 
  
  # create dichotomic for contract type
  
  mutate(work_16_dic = fct_recode(work_16,
                                  "Yes" = "Temporary contract",
                                  "No" = "Fixed contract"),
         work_16_dic = factor(work_16_dic,
                              levels = c("Yes", 
                                         "No"),
                              ordered = FALSE)
  ) |> 
  
  # recode violence
  
   mutate(
    across(
      all_of(exp_vio),
      ~ factor(
        fct_collapse(.x,
                     Yes = c("Yes, daily", 
                             "Yes, weekly", 
                             "Yes, monthly", 
                             "Yes, a few times"),
                     No = "No"
        ),
        levels = c("No", "Yes"), ordered = FALSE
      ),
      .names = "{.col}_dic"
    )
  ) |>
  
  # Recode protocols, drop "Do not know", ensure factor levels
 
   mutate(
     work_29_dic = fct_recode(work_29, 
                              NULL = "Do not know")
    ) |> 

  # relevel protocols

  mutate(
    work_29_dic = fct_relevel(work_29_dic, "No")
    ) |> 
  
  # recode support 
  
  mutate(
    across(
      all_of(c("work_21", "work_22")),
      ~ factor(
        fct_collapse(.x,
                     Yes = c("Always", "Often"),
                     No = c("Sometimes", "Seldom", "Never / Hardly ever")
        ),
        levels = c("Yes", "No"), ordered = FALSE
      ),
      .names = "{col}_dic"
    )
  ) |> 
  
  # recode meaningful career
  
  mutate(
    wb_wami_1_dic = fct_collapse(wb_wami_1,
                                 "Yes" = c("Absolutely true", "Mostly true"),
                                 "No" = c("Absolutely untrue", 
                                          "Mostly untrue"),
                                 NULL = "Neither true nor untrue"),
    wb_wami_1_dic = factor(wb_wami_1_dic, levels = c("Yes", "No"))
  ) |> 
  
  # recode purpose
  
  mutate(
    wb_wami_2_dic = fct_collapse(wb_wami_2,
                                 "Yes" = c("Absolutely true", "Mostly true"),
                                 "No" = c("Absolutely untrue", 
                                          "Mostly untrue"),
                                 NULL = "Neither true nor untrue"),
    wb_wami_2_dic = factor(wb_wami_2_dic, levels = c("Yes", "No"))
  )




outcomes <- c("phq_co", "gad_co", "suic_idea")


# Poisson models need numeric values

ds_ua <- 
  
  ds_ua |> 
  mutate(
    across(
      all_of(outcomes),
      ~ case_when(
        . == "Yes" ~ 1,
        . == "No" ~ 0,
        TRUE ~ NA_real_
      )
    )
  )

exposures <- c("work_21_dic", "work_22_dic",
               "work_30_dic", "work_31_dic", 
               "work_32_dic", "work_33_dic",
               "wb_wami_1_dic", "wb_wami_2_dic")


# Remove observations
ds_ua <- 
  ds_ua |> 
  filter(scdm_1 != "Less than 20 years old") |> 
  mutate(scdm_1 = fct_drop(scdm_1),
         loc_3 = fct_drop(loc_3)) |> 
  mutate(
    across(
      where(is.ordered),
      ~ factor(., ordered = FALSE)
    )
  ) |> 
  mutate(
    across(
      all_of(exposures),
      ~ factor(.x, levels = c("No", "Yes"))
    )
  )



# labels


for (i in 1:nrow(variable_labels)) {
  uuid <- variable_labels$Question_uuid[i]
  label <-  variable_labels$Label[i]
  ds_ua[[uuid]] <- sjlabelled::set_label(ds_ua[[uuid]], label)
}

rm(variable_labels,
   i,
   uuid,
   label)

outcome_order <- c(
  "Depression",
  "Anxiety",
  "Suicide thoughts"
  )

exposure_order <- c(
  "Bullying",
  "Sexual Harassment",
  "Violent threats",
  "Physical violence",
  "Colleague support",
  "Support from superiors",
  "Meaning in work",
  "Purpose in work"
)

adjustment_order <- c(
  "Crude",
  "Partially adjusted",
  "Fully adjusted"
  )

# define covariates and outcomes

outcomes_list <- c("phq_co", "gad_co", "suic_idea")

# for model 2 in each
covars_structural <- c("conflict", "scdm_1_rec", "scdm_2_rec")

# specific

covars_peers <- c("work_5_rec", "work_3_rec")

covars_harbul <- c("work_5_rec", "work_1", "work_3_rec")
  
covars_viol <- c("work_5_rec")

covars_meansup <- c("work_5_rec", "scdm_4_dic", "scdm_5_dic", "work_3_rec")

# assign covariates to each exposure
exposure_map <- list(
  
  "work_21_dic" = covars_peers,
  "work_22_dic" = covars_peers,
  
  "work_30_dic" = covars_harbul,
  "work_33_dic" = covars_harbul,
  
  "work_31_dic" = covars_viol,
  "work_32_dic" = covars_viol,
  
  "wb_wami_1_dic" = covars_meansup,
  "wb_wami_2_dic" = covars_meansup
)

Unweighted tables

scdm_vars <- c("scdm_1_rec", "scdm_4_dic", "scdm_5_dic", "work_1",
               "work_3_rec", "work_5_rec", "conflict")

scdm_tbl <- 
  ds_ua |> 
  select(all_of(scdm_vars), work_2, scdm_2_rec) |> 
  tbl_strata(
    strata = "work_2",
    ~ tbl_summary(
      .,
      by = "scdm_2_rec",
      missing_text = "Missing values"
    ) |> 
      add_overall()
  ) |> 
  as_gt() |> 
  tab_footnote(footnote = "Conflict zones are defined by Proximity to combat areas and occupied territories.")
## 30 missing rows in the "scdm_2_rec" column have been removed.
## 38 missing rows in the "scdm_2_rec" column have been removed.
scdm_tbl
Characteristic
Doctor
Nurse
Overall
N = 10,158
1
Female
N = 7,662
1
Male
N = 2,496
1
Overall
N = 13,579
1
Female
N = 12,744
1
Male
N = 835
1
Age groups (Recoded)





    20-30 1,694 (17%) 1,214 (16%) 480 (19%) 2,142 (16%) 1,866 (15%) 276 (33%)
    31-45 3,330 (33%) 2,567 (34%) 763 (31%) 5,181 (38%) 4,931 (39%) 250 (30%)
    46-55 2,063 (20%) 1,561 (20%) 502 (20%) 3,999 (29%) 3,793 (30%) 206 (25%)
    Over 55 3,071 (30%) 2,320 (30%) 751 (30%) 2,257 (17%) 2,154 (17%) 103 (12%)
Relationship status





    No partner 3,507 (35%) 2,843 (37%) 664 (27%) 4,541 (33%) 4,233 (33%) 308 (37%)
    Has a partner 6,639 (65%) 4,811 (63%) 1,828 (73%) 9,027 (67%) 8,500 (67%) 527 (63%)
    Missing values 12 8 4 11 11 0
Having children in the household





    Has children 6,449 (64%) 4,940 (65%) 1,509 (61%) 9,982 (74%) 9,497 (75%) 485 (58%)
    No children 3,692 (36%) 2,711 (35%) 981 (39%) 3,574 (26%) 3,224 (25%) 350 (42%)
    Missing values 17 11 6 23 23 0
Post-graduate training 1,026 (10%) 738 (9.7%) 288 (12%) 1,140 (8.4%) 1,026 (8.1%) 114 (14%)
    Missing values 26 21 5 81 79 2
Length of service (Recoded)





    5 years or less 1,836 (18%) 1,371 (18%) 465 (19%) 1,281 (9.6%) 1,087 (8.7%) 194 (24%)
    6-10 years 1,209 (12%) 885 (12%) 324 (13%) 1,431 (11%) 1,310 (10%) 121 (15%)
    More than 10 years 6,943 (70%) 5,272 (70%) 1,671 (68%) 10,613 (80%) 10,117 (81%) 496 (61%)
    Missing values 170 134 36 254 230 24
Healthcare setting (Recoded)





    Outpatient care 6,000 (60%) 4,935 (66%) 1,065 (43%) 5,703 (43%) 5,571 (45%) 132 (16%)
    In-hospital care 3,117 (31%) 2,054 (27%) 1,063 (43%) 5,030 (38%) 4,920 (40%) 110 (14%)
    Emergencies 835 (8.4%) 508 (6.8%) 327 (13%) 2,417 (18%) 1,856 (15%) 561 (70%)
    Missing values 206 165 41 429 397 32
Proximity to combat areas and occupied territories





    No conflict zone 8,440 (83%) 6,304 (82%) 2,136 (86%) 11,031 (81%) 10,345 (81%) 686 (82%)
    Conflict zone 1,718 (17%) 1,358 (18%) 360 (14%) 2,548 (19%) 2,399 (19%) 149 (18%)
Conflict zones are defined by Proximity to combat areas and occupied territories.
1 n (%)
gtsave(scdm_tbl, "out/tables/scdm_tbl_unw.docx")
# We calculate the prevalences with confidence intervals
# Good practice because it gives certain information about the sample

# Run for your outcomes
tbl_depression_u <- 
  generate_unweighted_table_out(ds_ua, "phq_co",
                                "Probable Depression")

gtsave(tbl_depression_u, "out/tables/dep_by_scdm_unweighted.docx")

tbl_anxiety_u <- 
  generate_unweighted_table_out(ds_ua, "gad_co", "Probable Anxiety")

gtsave(tbl_anxiety_u, "out/tables/anx_by_scdm_unweighted.docx")

tbl_suic_u <- 
  generate_unweighted_table_out(ds_ua, "suic_idea",
                                "Passive suicide thoughts")

gtsave(tbl_suic_u, "out/tables/suic_by_scdm_unweighted.docx")

# Display
tbl_depression_u
Probable Depression (Unweighted)
Doctor
Nurse
Male
(N = 2,129)
Female
(N = 6,431)
Overall
(N = 8,578)
Male
(N = 677)
Female
(N = 10,313)
Overall
(N = 11,017)
Overall
Overall 33.8% (31.8-35.9) 35.5% (34.4-36.7) 35.1% (34.1-36.2) 27.5% (24.2-31.0) 22.4% (21.6-23.3) 22.7% (21.9-23.5)
Age groups (Recoded)
20-30 46.1% (41.2-51.1) 48.3% (45.1-51.4) 47.6% (45.0-50.3) 34.8% (28.7-41.5) 32.7% (30.3-35.1) 32.9% (30.7-35.2)
31-45 45.8% (41.9-49.6) 42.3% (40.2-44.5) 43.2% (41.3-45.0) 29.9% (23.8-36.8) 23.8% (22.5-25.2) 24.1% (22.8-25.5)
46-55 27.4% (23.3-31.9) 36.2% (33.6-38.8) 34.1% (31.9-36.4) 23.7% (17.6-30.9) 22.3% (20.8-23.8) 22.3% (20.9-23.8)
Over 55 17.8% (15.0-21.1) 21.0% (19.3-22.9) 20.2% (18.7-21.9) 8.8% (3.9-17.7) 10.7% (9.3-12.3) 10.6% (9.2-12.1)
Relationship status
No partner 44.8% (40.6-49.0) 36.2% (34.3-38.2) 37.9% (36.2-39.7) 31.5% (25.9-37.7) 25.1% (23.7-26.7) 25.6% (24.2-27.1)
Has a partner 30.0% (27.7-32.3) 35.1% (33.7-36.6) 33.7% (32.5-34.9) 25.1% (21.1-29.5) 21.1% (20.2-22.1) 21.3% (20.4-22.2)
Having children in the household
Has children 29.8% (27.3-32.4) 33.6% (32.2-35.1) 32.7% (31.5-34.0) 25.6% (21.5-30.3) 21.3% (20.4-22.2) 21.4% (20.6-22.4)
No children 39.8% (36.5-43.3) 39.0% (37.0-41.1) 39.3% (37.6-41.0) 30.0% (24.8-35.8) 25.9% (24.3-27.7) 26.4% (24.8-28.0)
Post-graduate training
No 35.0% (32.8-37.2) 35.8% (34.6-37.1) 35.7% (34.6-36.7) 27.0% (23.5-30.8) 22.6% (21.7-23.4) 22.8% (22.0-23.6)
Yes 24.3% (19.1-30.5) 32.5% (28.6-36.6) 30.0% (26.9-33.4) 31.0% (21.8-42.0) 20.7% (17.8-23.8) 21.7% (18.9-24.7)
Length of service (Recoded)
5 years or less 42.3% (37.4-47.4) 45.2% (42.2-48.1) 44.4% (41.9-47.0) 34.0% (26.7-42.1) 32.3% (29.1-35.6) 32.5% (29.7-35.6)
6-10 years 51.1% (45.1-57.0) 47.7% (44.1-51.3) 48.5% (45.4-51.5) 32.3% (23.5-42.6) 27.0% (24.4-29.8) 27.4% (24.9-30.1)
More than 10 years 27.9% (25.6-30.3) 31.1% (29.8-32.5) 30.4% (29.2-31.6) 24.1% (20.2-28.5) 20.9% (20.0-21.8) 21.0% (20.2-21.9)
Healthcare setting (Recoded)
Outpatient care 32.9% (29.9-36.1) 34.9% (33.4-36.3) 34.5% (33.2-35.9) 25.9% (18.3-35.2) 22.8% (21.6-24.0) 22.8% (21.6-24.0)
In-hospital care 34.8% (31.7-38.0) 36.1% (33.9-38.4) 35.7% (33.9-37.5) 25.8% (17.4-36.4) 20.9% (19.7-22.2) 21.0% (19.8-22.3)
Emergencies 33.7% (28.3-39.5) 40.5% (35.9-45.3) 37.7% (34.2-41.3) 28.2% (24.3-32.5) 25.9% (23.7-28.2) 26.5% (24.5-28.5)
Proximity to combat areas and occupied territories
No conflict zone 33.8% (31.6-36.0) 35.5% (34.2-36.8) 35.1% (34.0-36.2) 26.3% (22.7-30.2) 21.9% (21.0-22.8) 22.1% (21.3-23.0)
Conflict zone 34.0% (28.7-39.7) 35.9% (33.1-38.8) 35.5% (33.1-38.1) 32.5% (24.6-41.5) 24.9% (23.0-26.9) 25.4% (23.5-27.3)
Unweighted Prevalence (95% CI).
tbl_anxiety_u
Probable Anxiety (Unweighted)
Doctor
Nurse
Male
(N = 2,134)
Female
(N = 6,438)
Overall
(N = 8,590)
Male
(N = 680)
Female
(N = 10,323)
Overall
(N = 11,030)
Overall
Overall 21.7% (20.0-23.5) 25.7% (24.6-26.8) 24.7% (23.8-25.7) 16.3% (13.7-19.4) 16.6% (15.9-17.3) 16.6% (15.9-17.3)
Age groups (Recoded)
20-30 29.3% (25.0-34.1) 36.5% (33.6-39.6) 34.6% (32.1-37.1) 20.1% (15.2-26.1) 24.2% (22.0-26.5) 23.7% (21.7-25.8)
31-45 29.2% (25.8-32.9) 30.9% (28.9-32.9) 30.6% (28.9-32.3) 18.0% (13.2-24.2) 16.6% (15.4-17.8) 16.7% (15.6-17.8)
46-55 17.7% (14.3-21.7) 25.7% (23.4-28.1) 23.7% (21.8-25.8) 13.0% (8.5-19.3) 16.9% (15.6-18.3) 16.7% (15.5-18.1)
Over 55 11.6% (9.3-14.4) 14.4% (12.9-16.1) 13.7% (12.4-15.1) 8.5% (3.8-17.3) 9.5% (8.2-11.0) 9.4% (8.1-10.9)
Relationship status
No partner 28.9% (25.2-32.8) 25.5% (23.8-27.3) 26.2% (24.6-27.8) 19.6% (15.0-25.1) 18.4% (17.2-19.8) 18.6% (17.3-19.9)
Has a partner 19.2% (17.3-21.3) 25.8% (24.4-27.2) 24.0% (22.9-25.1) 14.4% (11.2-18.1) 15.7% (14.8-16.6) 15.6% (14.8-16.4)
Having children in the household
Has children 19.3% (17.2-21.5) 23.9% (22.7-25.3) 22.9% (21.8-24.0) 14.1% (10.9-18.0) 15.8% (15.0-16.6) 15.7% (14.9-16.5)
No children 25.3% (22.4-28.4) 28.9% (27.1-30.8) 28.0% (26.4-29.6) 19.4% (15.1-24.6) 19.0% (17.5-20.6) 19.1% (17.7-20.6)
Post-graduate training
No 22.1% (20.2-24.0) 26.0% (24.9-27.1) 25.1% (24.1-26.1) 16.6% (13.7-19.9) 16.7% (16.0-17.5) 16.7% (16.0-17.5)
Yes 18.2% (13.6-23.9) 22.4% (19.0-26.2) 21.2% (18.4-24.2) 14.8% (8.4-24.3) 15.1% (12.6-17.9) 14.9% (12.6-17.6)
Length of service (Recoded)
5 years or less 26.4% (22.2-31.1) 33.8% (31.0-36.6) 32.0% (29.6-34.4) 19.0% (13.3-26.3) 24.5% (21.6-27.5) 23.6% (21.0-26.4)
6-10 years 32.0% (26.7-37.9) 35.4% (32.0-38.9) 34.4% (31.6-37.4) 19.0% (12.1-28.3) 20.1% (17.8-22.7) 20.0% (17.8-22.4)
More than 10 years 18.4% (16.5-20.5) 22.1% (20.9-23.3) 21.2% (20.2-22.3) 14.8% (11.7-18.6) 15.4% (14.6-16.2) 15.4% (14.6-16.1)
Healthcare setting (Recoded)
Outpatient care 22.1% (19.5-25.0) 25.9% (24.6-27.3) 25.3% (24.1-26.5) 16.1% (10.1-24.5) 17.4% (16.4-18.6) 17.4% (16.4-18.5)
In-hospital care 22.2% (19.6-25.0) 24.8% (22.8-26.9) 23.9% (22.3-25.6) 15.7% (9.2-25.3) 14.6% (13.6-15.8) 14.6% (13.6-15.8)
Emergencies 19.2% (14.9-24.3) 27.2% (23.2-31.7) 24.2% (21.2-27.5) 16.5% (13.4-20.2) 19.5% (17.5-21.6) 18.8% (17.1-20.6)
Proximity to combat areas and occupied territories
No conflict zone 21.8% (20.0-23.8) 25.4% (24.2-26.6) 24.5% (23.5-25.5) 15.5% (12.7-18.9) 15.9% (15.1-16.7) 15.9% (15.1-16.7)
Conflict zone 20.8% (16.5-25.9) 27.2% (24.7-29.9) 25.9% (23.7-28.2) 19.8% (13.5-28.1) 19.6% (17.8-21.4) 19.6% (18.0-21.4)
Unweighted Prevalence (95% CI).
tbl_suic_u
Passive suicide thoughts (Unweighted)
Doctor
Nurse
Male
(N = 2,137)
Female
(N = 6,460)
Overall
(N = 8,615)
Male
(N = 682)
Female
(N = 10,367)
Overall
(N = 11,076)
Overall
Overall 15.2% (13.7-16.8) 11.4% (10.6-12.2) 12.3% (11.7-13.1) 12.6% (10.3-15.4) 8.0% (7.5-8.5) 8.3% (7.8-8.8)
Age groups (Recoded)
20-30 22.5% (18.6-26.9) 18.4% (16.1-20.9) 19.6% (17.6-21.8) 17.3% (12.8-23.1) 14.1% (12.4-16.0) 14.5% (12.9-16.3)
31-45 20.8% (17.8-24.1) 13.1% (11.7-14.7) 15.0% (13.7-16.4) 11.7% (7.8-17.1) 7.7% (6.9-8.5) 7.9% (7.1-8.8)
46-55 11.4% (8.7-14.9) 11.1% (9.5-13.0) 11.2% (9.8-12.8) 10.7% (6.6-16.5) 7.8% (6.9-8.8) 8.0% (7.1-8.9)
Over 55 7.3% (5.5-9.7) 6.0% (5.0-7.2) 6.3% (5.4-7.3) 6.0% (2.2-14.1) 3.8% (3.0-4.9) 3.9% (3.1-4.9)
Relationship status
No partner 21.7% (18.4-25.4) 13.5% (12.1-14.9) 15.0% (13.7-16.4) 16.0% (11.9-21.2) 10.5% (9.5-11.6) 10.9% (9.9-11.9)
Has a partner 13.0% (11.4-14.7) 10.2% (9.3-11.1) 11.0% (10.2-11.8) 10.6% (7.9-14.0) 6.8% (6.2-7.4) 7.0% (6.4-7.6)
Having children in the household
Has children 12.8% (11.1-14.8) 10.1% (9.2-11.1) 10.8% (10.0-11.6) 10.3% (7.6-13.9) 7.0% (6.5-7.6) 7.2% (6.6-7.8)
No children 18.9% (16.3-21.7) 13.6% (12.3-15.1) 15.1% (13.8-16.4) 15.8% (11.9-20.7) 10.8% (9.7-12.1) 11.3% (10.2-12.6)
Post-graduate training
No 15.1% (13.6-16.8) 11.2% (10.4-12.1) 12.2% (11.5-13.0) 12.3% (9.8-15.3) 7.9% (7.4-8.4) 8.1% (7.6-8.7)
Yes 15.9% (11.6-21.4) 12.8% (10.2-15.9) 13.6% (11.4-16.3) 14.8% (8.4-24.3) 9.4% (7.4-11.8) 9.9% (8.0-12.2)
Length of service (Recoded)
5 years or less 21.9% (18.0-26.3) 16.0% (13.9-18.2) 17.5% (15.7-19.5) 20.8% (14.8-28.2) 13.0% (10.8-15.4) 14.2% (12.1-16.5)
6-10 years 24.6% (19.8-30.1) 15.4% (13.0-18.2) 17.9% (15.6-20.3) 13.0% (7.4-21.6) 12.8% (10.9-15.0) 12.8% (11.0-14.9)
More than 10 years 11.6% (10.0-13.4) 9.6% (8.7-10.5) 10.1% (9.3-10.9) 9.6% (7.1-12.9) 6.9% (6.3-7.4) 7.0% (6.5-7.6)
Healthcare setting (Recoded)
Outpatient care 15.6% (13.3-18.1) 11.0% (10.1-12.0) 11.9% (11.0-12.8) 9.7% (5.2-17.1) 7.9% (7.1-8.7) 7.9% (7.2-8.7)
In-hospital care 15.6% (13.3-18.1) 11.1% (9.7-12.7) 12.7% (11.5-14.0) 10.1% (5.0-18.8) 7.2% (6.4-8.0) 7.2% (6.5-8.1)
Emergencies 13.0% (9.5-17.5) 15.7% (12.5-19.5) 14.6% (12.2-17.4) 13.8% (10.9-17.3) 10.5% (9.0-12.1) 11.3% (10.0-12.8)
Proximity to combat areas and occupied territories
No conflict zone 15.8% (14.2-17.6) 11.2% (10.4-12.1) 12.4% (11.7-13.2) 12.2% (9.7-15.3) 7.8% (7.2-8.4) 8.0% (7.5-8.6)
Conflict zone 11.6% (8.3-15.8) 12.1% (10.3-14.2) 12.0% (10.4-13.8) 14.3% (8.9-21.9) 8.8% (7.6-10.2) 9.2% (8.1-10.6)
Unweighted Prevalence (95% CI).
# Run function for your outcomes
tbl_harassment_u <- generate_unweighted_table_exp(ds_ua, "work_30_dic", 
                                              "Sexual harassment")
gtsave(tbl_harassment_u, "out/tables/harass_by_scdm_unweighted.docx")

tbl_threats_u <- generate_unweighted_table_exp(ds_ua, "work_31_dic", 
                                           "Violent threats")
gtsave(tbl_threats_u, "out/tables/threats_by_scdm_unweighted.docx")

tbl_violence_u <- generate_unweighted_table_exp(ds_ua, "work_32_dic", 
                                            "Physical violence")
gtsave(tbl_violence_u, "out/tables/violence_by_scdm_unweighted.docx")

tbl_bullying_u <- generate_unweighted_table_exp(ds_ua, "work_33_dic", 
                                            "Bullying")
gtsave(tbl_bullying_u, "out/tables/bullying_by_scdm_unweighted.docx")

tbl_colleagues_u <- generate_unweighted_table_exp(ds_ua, "work_21_dic",
                                              "Colleague support")
gtsave(tbl_colleagues_u, "out/tables/col_supp_by_scdm_unweighted.docx")

tbl_superiors_u <- generate_unweighted_table_exp(ds_ua,"work_22_dic", 
                                         "Support from superiors")
gtsave(tbl_superiors_u, "out/tables/sup_supp_by_scdm_unweighted.docx")
 
tbl_meaning_u <- generate_unweighted_table_exp(ds_ua, "wb_wami_1_dic", 
                                           "Meaning in work")
gtsave(tbl_meaning_u, "out/tables/meaning_by_scdm_unweighted.docx")

tbl_purpose_u <- generate_unweighted_table_exp(ds_ua, "wb_wami_2_dic", 
                                           "Purpose in work")
gtsave(tbl_purpose_u, "out/tables/purpose_by_scdm_unweighted.docx")

# Visualize

tbl_harassment_u
Sexual harassment (Unweighted)
Doctor
Nurse
Male
(N = 2,226)
Female
(N = 6,705)
Overall
(N = 8,951)
Male
(N = 716)
Female
(N = 10,765)
Overall
(N = 11,510)
Overall
Overall 8.2% (7.1-9.5) 9.8% (9.1-10.5) 9.4% (8.8-10.1) 8.8% (6.9-11.2) 6.8% (6.3-7.3) 6.9% (6.4-7.4)
Age groups (Recoded)
20-30 14.1% (11.0-17.8) 22.3% (19.9-25.0) 20.0% (18.1-22.2) 12.2% (8.4-17.2) 16.9% (15.1-18.9) 16.3% (14.6-18.1)
31-45 10.9% (8.7-13.5) 13.1% (11.7-14.6) 12.6% (11.4-13.9) 7.9% (4.8-12.6) 7.2% (6.5-8.1) 7.3% (6.5-8.1)
46-55 6.2% (4.3-9.0) 6.1% (4.9-7.5) 6.2% (5.2-7.5) 6.3% (3.3-11.3) 4.3% (3.7-5.1) 4.4% (3.8-5.2)
Over 55 3.0% (1.9-4.7) 2.0% (1.5-2.8) 2.3% (1.8-3.0) 6.8% (2.8-14.8) 1.3% (0.8-2.0) 1.5% (1.1-2.2)
Relationship status
No partner 14.5% (11.8-17.7) 12.4% (11.1-13.7) 12.9% (11.7-14.1) 11.9% (8.4-16.6) 9.3% (8.3-10.3) 9.4% (8.5-10.4)
Has a partner 6.0% (4.9-7.3) 8.3% (7.5-9.1) 7.6% (7.0-8.4) 6.9% (4.8-9.8) 5.6% (5.1-6.1) 5.7% (5.2-6.2)
Having children in the household
Has children 6.0% (4.8-7.4) 7.7% (6.9-8.6) 7.3% (6.7-8.1) 7.0% (4.8-10.0) 5.9% (5.4-6.4) 6.0% (5.5-6.5)
No children 11.7% (9.7-14.1) 13.5% (12.2-15.0) 13.1% (12.0-14.3) 11.3% (8.0-15.5) 9.4% (8.4-10.6) 9.6% (8.6-10.7)
Post-graduate training
No 7.8% (6.7-9.1) 9.4% (8.7-10.2) 9.1% (8.4-9.7) 7.9% (5.9-10.4) 6.6% (6.1-7.1) 6.6% (6.2-7.1)
Yes 11.7% (8.1-16.6) 13.8% (11.1-17.0) 13.2% (11.0-15.8) 15.1% (8.8-24.3) 9.4% (7.5-11.8) 10.1% (8.2-12.3)
Length of service (Recoded)
5 years or less 14.9% (11.7-18.8) 19.9% (17.7-22.3) 18.7% (16.8-20.7) 11.1% (6.9-17.2) 18.5% (16.0-21.2) 17.3% (15.1-19.8)
6-10 years 11.2% (8.0-15.5) 16.1% (13.6-18.9) 14.7% (12.7-17.0) 13.0% (7.5-21.1) 11.1% (9.3-13.1) 11.2% (9.5-13.1)
More than 10 years 5.8% (4.7-7.2) 6.1% (5.5-6.9) 6.1% (5.5-6.8) 7.0% (4.9-9.9) 5.0% (4.6-5.5) 5.1% (4.7-5.6)
Healthcare setting (Recoded)
Outpatient care 6.6% (5.1-8.4) 9.0% (8.1-9.9) 8.6% (7.9-9.4) 11.1% (6.3-18.6) 5.2% (4.6-5.9) 5.3% (4.8-6.0)
In-hospital care 9.4% (7.7-11.5) 10.5% (9.1-12.0) 10.2% (9.1-11.4) 11.1% (5.7-19.9) 7.1% (6.3-7.9) 7.1% (6.4-8.0)
Emergencies 9.6% (6.6-13.6) 14.8% (11.7-18.5) 12.8% (10.6-15.5) 7.7% (5.6-10.4) 10.8% (9.3-12.4) 10.0% (8.8-11.4)
Proximity to combat areas and occupied territories
No conflict zone 8.5% (7.3-9.8) 9.9% (9.2-10.7) 9.6% (9.0-10.3) 8.4% (6.3-11.0) 6.9% (6.4-7.5) 7.0% (6.5-7.5)
Conflict zone 6.7% (4.3-10.1) 9.1% (7.5-10.9) 8.6% (7.2-10.2) 10.7% (6.2-17.6) 6.2% (5.2-7.4) 6.5% (5.5-7.7)
Unweighted Prevalence (95% CI)
tbl_threats_u
Violent threats (Unweighted)
Doctor
Nurse
Male
(N = 2,218)
Female
(N = 6,689)
Overall
(N = 8,927)
Male
(N = 715)
Female
(N = 10,744)
Overall
(N = 11,488)
Overall
Overall 27.2% (25.4-29.1) 17.6% (16.7-18.6) 20.1% (19.2-20.9) 29.0% (25.7-32.5) 10.2% (9.7-10.8) 11.4% (10.8-12.0)
Age groups (Recoded)
20-30 35.0% (30.5-39.7) 23.7% (21.2-26.4) 27.0% (24.8-29.4) 31.8% (26.0-38.2) 15.6% (13.8-17.5) 17.8% (16.1-19.7)
31-45 35.2% (31.7-39.0) 20.8% (19.2-22.6) 24.2% (22.7-25.8) 28.8% (23.0-35.5) 11.1% (10.2-12.1) 12.0% (11.0-13.0)
46-55 24.1% (20.3-28.4) 17.3% (15.3-19.4) 18.9% (17.2-20.8) 28.7% (22.3-36.2) 8.8% (7.9-9.8) 9.8% (8.9-10.9)
Over 55 16.1% (13.4-19.1) 11.2% (9.9-12.7) 12.4% (11.2-13.7) 21.8% (14.0-32.2) 6.2% (5.1-7.4) 6.8% (5.8-8.1)
Relationship status
No partner 31.4% (27.7-35.4) 18.8% (17.3-20.4) 21.3% (19.9-22.8) 32.0% (26.5-38.0) 12.1% (11.1-13.3) 13.5% (12.5-14.7)
Has a partner 25.8% (23.7-28.0) 16.9% (15.8-18.1) 19.4% (18.4-20.5) 27.1% (23.1-31.6) 9.3% (8.7-10.0) 10.3% (9.7-11.1)
Having children in the household
Has children 26.9% (24.5-29.3) 17.0% (15.9-18.1) 19.3% (18.3-20.4) 29.1% (24.8-33.7) 9.7% (9.0-10.3) 10.6% (10.0-11.3)
No children 27.7% (24.8-30.9) 18.8% (17.3-20.5) 21.2% (19.9-22.7) 28.8% (23.8-34.3) 11.9% (10.8-13.3) 13.7% (12.5-15.0)
Post-graduate training
No 27.0% (25.1-29.1) 17.9% (16.9-18.8) 20.1% (19.3-21.0) 29.1% (25.6-32.9) 10.1% (9.5-10.7) 11.2% (10.6-11.8)
Yes 28.7% (23.2-34.9) 15.4% (12.6-18.7) 19.4% (16.8-22.3) 28.0% (19.4-38.4) 12.1% (9.9-14.6) 13.8% (11.6-16.3)
Length of service (Recoded)
5 years or less 32.0% (27.6-36.8) 20.2% (18.0-22.6) 23.3% (21.3-25.5) 28.8% (22.2-36.5) 13.8% (11.6-16.3) 16.1% (14.0-18.5)
6-10 years 38.9% (33.3-44.8) 24.1% (21.2-27.2) 28.0% (25.4-30.8) 36.4% (27.5-46.4) 13.9% (12.0-16.1) 15.9% (13.9-18.1)
More than 10 years 23.7% (21.6-26.0) 15.9% (14.9-17.0) 17.8% (16.9-18.8) 27.3% (23.3-31.8) 9.4% (8.8-10.0) 10.3% (9.7-10.9)
Healthcare setting (Recoded)
Outpatient care 24.4% (21.8-27.3) 17.1% (16.0-18.3) 18.4% (17.4-19.5) 18.8% (12.4-27.3) 7.6% (6.9-8.4) 7.9% (7.2-8.7)
In-hospital care 26.7% (23.9-29.6) 16.1% (14.4-17.9) 19.8% (18.3-21.3) 16.9% (10.0-26.6) 9.5% (8.6-10.4) 9.6% (8.7-10.5)
Emergencies 37.7% (32.3-43.5) 28.9% (24.8-33.4) 32.5% (29.2-36.0) 33.3% (29.2-37.6) 20.4% (18.4-22.5) 23.5% (21.7-25.4)
Proximity to combat areas and occupied territories
No conflict zone 27.8% (25.8-29.9) 18.0% (17.0-19.0) 20.5% (19.6-21.4) 27.9% (24.3-31.8) 10.2% (9.6-10.9) 11.3% (10.7-12.0)
Conflict zone 23.7% (19.3-28.8) 16.1% (14.0-18.3) 17.8% (15.9-19.8) 33.6% (25.7-42.4) 10.4% (9.1-11.8) 11.8% (10.5-13.3)
Unweighted Prevalence (95% CI)
tbl_violence_u
Physical violence (Unweighted)
Doctor
Nurse
Male
(N = 2,218)
Female
(N = 6,677)
Overall
(N = 8,915)
Male
(N = 713)
Female
(N = 10,733)
Overall
(N = 11,474)
Overall
Overall 5.5% (4.6-6.6) 2.5% (2.2-2.9) 3.3% (2.9-3.7) 10.9% (8.8-13.5) 3.1% (2.8-3.5) 3.6% (3.3-4.0)
Age groups (Recoded)
20-30 9.6% (7.1-12.9) 4.9% (3.7-6.5) 6.3% (5.2-7.7) 10.1% (6.7-14.9) 6.1% (5.0-7.4) 6.6% (5.5-7.9)
31-45 5.8% (4.3-7.9) 3.2% (2.5-4.0) 3.9% (3.2-4.6) 10.2% (6.7-15.3) 3.3% (2.8-3.9) 3.6% (3.1-4.2)
46-55 4.0% (2.5-6.4) 1.8% (1.2-2.7) 2.3% (1.7-3.2) 10.3% (6.4-16.1) 2.3% (1.9-2.9) 2.7% (2.2-3.4)
Over 55 3.5% (2.3-5.3) 1.0% (0.6-1.6) 1.6% (1.2-2.2) 16.1% (9.4-25.9) 1.6% (1.1-2.3) 2.2% (1.6-3.0)
Relationship status
No partner 8.9% (6.8-11.6) 3.0% (2.4-3.8) 4.2% (3.5-5.0) 10.1% (6.9-14.5) 4.3% (3.7-5.1) 4.7% (4.1-5.5)
Has a partner 4.3% (3.4-5.4) 2.2% (1.8-2.7) 2.8% (2.4-3.3) 11.4% (8.7-14.8) 2.5% (2.2-2.9) 3.0% (2.7-3.5)
Having children in the household
Has children 4.5% (3.5-5.8) 2.2% (1.8-2.7) 2.8% (2.4-3.2) 10.9% (8.2-14.4) 2.9% (2.5-3.3) 3.3% (2.9-3.7)
No children 7.0% (5.5-9.0) 3.2% (2.5-4.0) 4.2% (3.6-5.0) 11.0% (7.8-15.2) 3.8% (3.1-4.6) 4.5% (3.8-5.3)
Post-graduate training
No 5.1% (4.2-6.2) 2.3% (2.0-2.7) 3.0% (2.7-3.4) 10.8% (8.5-13.6) 3.0% (2.6-3.3) 3.4% (3.1-3.8)
Yes 8.6% (5.5-13.0) 4.7% (3.2-6.9) 6.0% (4.5-7.9) 11.8% (6.3-20.6) 5.0% (3.6-6.8) 5.7% (4.3-7.5)
Length of service (Recoded)
5 years or less 8.9% (6.4-12.2) 4.8% (3.7-6.2) 5.9% (4.8-7.2) 8.6% (5.0-14.3) 6.3% (4.9-8.2) 6.7% (5.3-8.4)
6-10 years 7.2% (4.6-10.9) 3.0% (2.0-4.5) 4.1% (3.0-5.5) 10.4% (5.5-18.2) 4.3% (3.3-5.8) 4.9% (3.8-6.3)
More than 10 years 4.2% (3.3-5.4) 1.9% (1.5-2.3) 2.5% (2.1-2.9) 12.0% (9.2-15.4) 2.6% (2.3-3.0) 3.1% (2.7-3.5)
Healthcare setting (Recoded)
Outpatient care 4.2% (3.1-5.7) 1.9% (1.5-2.4) 2.3% (2.0-2.8) 6.8% (3.2-13.4) 1.6% (1.3-2.0) 1.7% (1.4-2.1)
In-hospital care 4.3% (3.1-5.8) 2.0% (1.5-2.8) 2.8% (2.3-3.5) 5.6% (2.1-13.2) 3.6% (3.1-4.2) 3.7% (3.1-4.3)
Emergencies 13.6% (10.0-18.1) 10.6% (8.0-13.9) 11.9% (9.7-14.5) 12.6% (9.9-15.9) 6.4% (5.2-7.7) 7.9% (6.8-9.1)
Proximity to combat areas and occupied territories
No conflict zone 5.7% (4.7-6.9) 2.6% (2.2-3.0) 3.4% (3.0-3.8) 10.3% (8.0-13.1) 3.2% (2.8-3.6) 3.6% (3.2-4.0)
Conflict zone 4.3% (2.5-7.3) 2.3% (1.6-3.4) 2.8% (2.1-3.8) 13.8% (8.6-21.3) 2.9% (2.2-3.8) 3.6% (2.8-4.5)
Unweighted Prevalence (95% CI)
tbl_bullying_u
Bullying (Unweighted)
Doctor
Nurse
Male
(N = 2,218)
Female
(N = 6,670)
Overall
(N = 8,907)
Male
(N = 710)
Female
(N = 10,717)
Overall
(N = 11,455)
Overall
Overall 24.5% (22.7-26.3) 27.4% (26.3-28.5) 26.7% (25.8-27.6) 22.0% (19.0-25.2) 18.1% (17.4-18.8) 18.3% (17.6-19.0)
Age groups (Recoded)
20-30 34.5% (30.0-39.3) 40.5% (37.5-43.5) 38.8% (36.3-41.3) 25.4% (20.1-31.6) 26.7% (24.5-29.0) 26.5% (24.5-28.7)
31-45 31.4% (28.0-35.1) 30.7% (28.8-32.6) 30.9% (29.2-32.6) 22.9% (17.6-29.2) 18.9% (17.8-20.2) 19.1% (17.9-20.3)
46-55 20.3% (16.7-24.4) 25.5% (23.2-27.9) 24.2% (22.3-26.3) 18.5% (13.2-25.3) 16.2% (15.0-17.5) 16.3% (15.1-17.6)
Over 55 13.6% (11.2-16.5) 18.1% (16.5-19.9) 17.0% (15.6-18.5) 17.2% (10.3-27.2) 11.9% (10.5-13.5) 12.2% (10.8-13.8)
Relationship status
No partner 33.5% (29.7-37.5) 29.3% (27.6-31.2) 30.2% (28.5-31.8) 24.4% (19.5-30.1) 21.6% (20.2-23.0) 21.7% (20.4-23.1)
Has a partner 21.3% (19.4-23.4) 26.2% (24.9-27.6) 24.9% (23.8-26.0) 20.5% (16.9-24.6) 16.4% (15.5-17.3) 16.6% (15.8-17.5)
Having children in the household
Has children 20.7% (18.6-23.0) 25.7% (24.4-27.0) 24.5% (23.4-25.6) 18.9% (15.3-23.1) 17.1% (16.3-18.0) 17.2% (16.4-18.0)
No children 30.3% (27.3-33.5) 30.4% (28.6-32.3) 30.4% (28.9-32.1) 26.2% (21.4-31.6) 21.0% (19.5-22.6) 21.5% (20.0-23.0)
Post-graduate training
No 23.8% (21.9-25.7) 27.3% (26.2-28.5) 26.5% (25.5-27.5) 21.3% (18.1-24.8) 17.9% (17.2-18.7) 18.1% (17.4-18.9)
Yes 29.9% (24.3-36.2) 27.8% (24.2-31.8) 28.4% (25.4-31.7) 26.9% (18.5-37.2) 20.1% (17.3-23.1) 20.7% (18.1-23.6)
Length of service (Recoded)
5 years or less 31.1% (26.7-35.8) 36.4% (33.7-39.2) 35.1% (32.8-37.5) 22.8% (16.8-30.2) 26.7% (23.9-29.8) 26.1% (23.5-28.9)
6-10 years 36.5% (31.1-42.3) 37.2% (33.8-40.6) 36.9% (34.1-39.9) 30.5% (22.1-40.3) 21.8% (19.4-24.4) 22.5% (20.2-25.0)
More than 10 years 20.3% (18.3-22.4) 23.4% (22.2-24.6) 22.7% (21.6-23.7) 19.7% (16.2-23.8) 16.7% (15.9-17.5) 16.8% (16.1-17.6)
Healthcare setting (Recoded)
Outpatient care 21.6% (19.1-24.4) 25.5% (24.2-26.8) 24.9% (23.7-26.0) 19.7% (13.1-28.2) 16.1% (15.1-17.1) 16.1% (15.1-17.2)
In-hospital care 26.6% (23.8-29.5) 30.9% (28.8-33.1) 29.4% (27.7-31.1) 21.3% (13.7-31.6) 19.3% (18.1-20.5) 19.3% (18.2-20.5)
Emergencies 27.2% (22.3-32.6) 31.6% (27.4-36.2) 30.0% (26.8-33.5) 22.5% (18.9-26.4) 21.0% (19.1-23.2) 21.4% (19.6-23.2)
Proximity to combat areas and occupied territories
No conflict zone 25.5% (23.6-27.5) 27.8% (26.7-29.0) 27.3% (26.3-28.3) 21.6% (18.3-25.2) 18.2% (17.4-19.1) 18.4% (17.6-19.2)
Conflict zone 18.5% (14.5-23.3) 25.1% (22.7-27.7) 23.7% (21.6-26.0) 23.8% (17.0-32.3) 17.4% (15.8-19.2) 17.7% (16.2-19.5)
Unweighted Prevalence (95% CI)
tbl_colleagues_u
Colleague support (Unweighted)
Doctor
Nurse
Male
(N = 2,259)
Female
(N = 6,804)
Overall
(N = 9,085)
Male
(N = 729)
Female
(N = 11,007)
Overall
(N = 11,765)
Overall
Overall 58.7% (56.7-60.8) 59.8% (58.7-61.0) 59.5% (58.5-60.5) 54.6% (50.9-58.2) 58.3% (57.3-59.2) 58.1% (57.2-58.9)
Age groups (Recoded)
20-30 54.9% (50.1-59.7) 60.0% (57.0-63.0) 58.5% (56.0-61.0) 57.0% (50.5-63.2) 58.7% (56.2-61.1) 58.5% (56.2-60.8)
31-45 53.0% (49.2-56.8) 54.8% (52.8-56.9) 54.3% (52.5-56.1) 48.8% (42.0-55.7) 54.5% (53.0-56.0) 54.2% (52.8-55.7)
46-55 60.7% (56.0-65.2) 60.3% (57.7-62.9) 60.4% (58.1-62.6) 56.5% (48.9-63.9) 59.5% (57.9-61.2) 59.4% (57.7-61.0)
Over 55 65.8% (62.1-69.4) 65.0% (62.8-67.0) 65.0% (63.2-66.8) 58.2% (47.4-68.3) 64.4% (62.2-66.6) 64.1% (61.9-66.3)
Relationship status
No partner 54.1% (50.0-58.2) 60.0% (58.1-61.9) 58.8% (57.0-60.5) 54.9% (48.8-60.9) 58.0% (56.3-59.6) 57.7% (56.2-59.3)
Has a partner 60.4% (58.0-62.8) 59.7% (58.2-61.2) 59.8% (58.6-61.1) 54.4% (49.7-59.0) 58.4% (57.3-59.5) 58.2% (57.1-59.3)
Having children in the household
Has children 60.0% (57.3-62.6) 60.0% (58.5-61.5) 59.9% (58.6-61.2) 54.0% (49.1-58.8) 57.9% (56.8-59.0) 57.8% (56.7-58.8)
No children 56.7% (53.3-60.0) 59.5% (57.5-61.5) 58.7% (57.0-60.4) 55.4% (49.6-61.0) 59.3% (57.4-61.1) 58.9% (57.1-60.6)
Post-graduate training
No 59.2% (57.0-61.4) 60.0% (58.8-61.2) 59.7% (58.6-60.8) 54.0% (50.1-58.0) 58.7% (57.8-59.7) 58.5% (57.5-59.4)
Yes 55.0% (48.6-61.2) 58.4% (54.2-62.4) 57.2% (53.8-60.6) 57.7% (47.3-67.6) 52.2% (48.6-55.7) 52.9% (49.5-56.2)
Length of service (Recoded)
5 years or less 57.7% (52.9-62.5) 61.6% (58.8-64.3) 60.5% (58.1-62.9) 61.7% (53.8-69.0) 60.6% (57.3-63.8) 60.8% (57.8-63.7)
6-10 years 50.7% (44.9-56.5) 55.7% (52.2-59.1) 54.1% (51.1-57.1) 51.4% (41.7-61.0) 57.6% (54.7-60.5) 57.2% (54.3-59.9)
More than 10 years 60.5% (58.0-62.9) 60.1% (58.7-61.5) 60.1% (58.9-61.3) 53.0% (48.3-57.7) 58.1% (57.1-59.1) 57.9% (56.9-58.9)
Healthcare setting (Recoded)
Outpatient care 58.3% (55.1-61.4) 58.2% (56.7-59.6) 58.1% (56.8-59.4) 66.7% (57.3-74.9) 59.2% (57.8-60.5) 59.3% (58.0-60.7)
In-hospital care 59.6% (56.5-62.7) 63.1% (60.9-65.3) 61.8% (60.0-63.6) 57.0% (46.3-67.1) 57.8% (56.3-59.3) 57.8% (56.3-59.3)
Emergencies 57.6% (51.8-63.2) 62.2% (57.5-66.6) 60.2% (56.6-63.6) 51.4% (47.0-55.7) 56.9% (54.4-59.3) 55.6% (53.4-57.7)
Proximity to combat areas and occupied territories
No conflict zone 58.0% (55.7-60.2) 59.7% (58.4-61.0) 59.2% (58.1-60.3) 55.4% (51.4-59.5) 58.2% (57.2-59.3) 58.1% (57.1-59.1)
Conflict zone 63.2% (57.7-68.4) 60.5% (57.6-63.2) 61.0% (58.5-63.4) 50.8% (42.0-59.5) 58.3% (56.1-60.5) 57.9% (55.8-59.9)
Unweighted Prevalence (95% CI)
tbl_superiors_u
Support from superiors (Unweighted)
Doctor
Nurse
Male
(N = 2,255)
Female
(N = 6,793)
Overall
(N = 9,070)
Male
(N = 729)
Female
(N = 10,974)
Overall
(N = 11,732)
Overall
Overall 49.5% (47.5-51.6) 52.7% (51.5-53.9) 51.8% (50.8-52.9) 48.7% (45.0-52.4) 51.2% (50.3-52.2) 51.1% (50.2-52.0)
Age groups (Recoded)
20-30 43.8% (39.1-48.6) 47.8% (44.8-50.8) 46.5% (44.0-49.1) 44.3% (38.0-50.7) 48.9% (46.4-51.4) 48.3% (46.0-50.6)
31-45 43.5% (39.8-47.3) 49.3% (47.2-51.4) 47.9% (46.1-49.7) 46.1% (39.4-53.0) 48.3% (46.8-49.9) 48.3% (46.8-49.7)
46-55 50.6% (45.8-55.3) 51.9% (49.3-54.6) 51.5% (49.2-53.8) 53.1% (45.5-60.6) 51.8% (50.1-53.5) 51.8% (50.2-53.5)
Over 55 58.8% (55.0-62.6) 59.6% (57.4-61.8) 59.3% (57.4-61.2) 58.2% (47.4-68.3) 59.1% (56.8-61.4) 59.2% (56.9-61.4)
Relationship status
No partner 47.4% (43.3-51.5) 52.7% (50.7-54.6) 51.5% (49.7-53.3) 46.5% (40.5-52.6) 51.3% (49.6-52.9) 50.9% (49.4-52.5)
Has a partner 50.3% (47.9-52.7) 52.7% (51.2-54.2) 52.0% (50.7-53.3) 50.0% (45.4-54.6) 51.2% (50.1-52.4) 51.2% (50.1-52.3)
Having children in the household
Has children 50.4% (47.8-53.1) 53.2% (51.7-54.7) 52.4% (51.1-53.7) 50.0% (45.3-54.7) 50.7% (49.7-51.8) 50.8% (49.7-51.8)
No children 48.1% (44.7-51.4) 51.9% (49.9-53.9) 50.7% (49.0-52.4) 46.9% (41.2-52.7) 52.7% (50.8-54.6) 52.1% (50.3-53.9)
Post-graduate training
No 48.9% (46.7-51.1) 52.2% (51.0-53.5) 51.3% (50.2-52.4) 46.8% (42.8-50.7) 50.6% (49.6-51.6) 50.4% (49.5-51.3)
Yes 54.6% (48.2-60.8) 57.7% (53.6-61.7) 56.5% (53.1-59.9) 60.8% (50.4-70.4) 59.4% (55.8-62.8) 59.7% (56.4-62.9)
Length of service (Recoded)
5 years or less 46.5% (41.7-51.3) 50.7% (47.9-53.6) 49.5% (47.1-52.0) 50.3% (42.5-58.1) 52.4% (49.1-55.6) 52.0% (49.0-55.1)
6-10 years 39.6% (34.0-45.4) 49.7% (46.2-53.2) 46.9% (43.9-49.9) 39.4% (30.4-49.3) 48.4% (45.4-51.3) 47.7% (44.8-50.5)
More than 10 years 52.3% (49.8-54.8) 53.7% (52.2-55.1) 53.2% (52.0-54.5) 50.1% (45.4-54.8) 51.5% (50.4-52.5) 51.5% (50.4-52.5)
Healthcare setting (Recoded)
Outpatient care 51.5% (48.3-54.7) 53.2% (51.7-54.7) 52.8% (51.5-54.1) 60.7% (51.2-69.5) 52.8% (51.4-54.2) 53.1% (51.7-54.4)
In-hospital care 48.1% (45.0-51.3) 52.4% (50.1-54.7) 50.9% (49.0-52.7) 45.2% (34.9-55.8) 49.6% (48.1-51.1) 49.5% (48.0-51.0)
Emergencies 48.0% (42.3-53.8) 48.7% (44.0-53.4) 48.2% (44.6-51.8) 46.5% (42.2-50.9) 50.6% (48.2-53.1) 49.7% (47.5-51.8)
Proximity to combat areas and occupied territories
No conflict zone 48.6% (46.3-50.9) 52.2% (50.9-53.5) 51.2% (50.0-52.3) 50.4% (46.3-54.5) 50.7% (49.7-51.7) 50.7% (49.7-51.7)
Conflict zone 55.0% (49.5-60.5) 55.1% (52.3-58.0) 55.0% (52.5-57.6) 40.9% (32.5-49.8) 53.6% (51.4-55.8) 52.8% (50.7-54.9)
Unweighted Prevalence (95% CI)
tbl_meaning_u
Meaning in work (Unweighted)
Doctor
Nurse
Male
(N = 1,718)
Female
(N = 5,289)
Overall
(N = 7,020)
Male
(N = 525)
Female
(N = 8,186)
Overall
(N = 8,733)
Overall
Overall 81.3% (79.3-83.1) 84.5% (83.4-85.4) 83.6% (82.7-84.5) 68.6% (64.4-72.5) 80.6% (79.8-81.5) 79.9% (79.1-80.7)
Age groups (Recoded)
20-30 78.5% (73.5-82.8) 83.7% (80.8-86.2) 82.2% (79.7-84.4) 64.1% (56.4-71.2) 80.8% (78.3-83.1) 78.5% (76.2-80.8)
31-45 80.3% (76.6-83.6) 82.1% (80.2-83.8) 81.6% (79.9-83.2) 72.8% (65.0-79.4) 77.8% (76.3-79.3) 77.6% (76.1-79.0)
46-55 80.9% (76.3-84.8) 82.5% (80.0-84.7) 82.1% (80.0-84.0) 68.3% (59.3-76.1) 80.9% (79.3-82.4) 80.3% (78.7-81.8)
Over 55 84.0% (80.6-87.0) 88.6% (87.0-90.1) 87.5% (86.0-88.8) 70.4% (58.2-80.4) 86.2% (84.3-87.9) 85.4% (83.6-87.2)
Relationship status
No partner 75.6% (71.2-79.5) 84.0% (82.3-85.6) 82.4% (80.8-83.9) 70.7% (63.8-76.8) 81.7% (80.2-83.2) 80.9% (79.4-82.3)
Has a partner 83.2% (81.0-85.2) 84.8% (83.5-86.0) 84.3% (83.2-85.3) 67.3% (61.9-72.3) 80.1% (79.0-81.1) 79.4% (78.3-80.4)
Having children in the household
Has children 82.3% (79.9-84.6) 84.2% (82.9-85.4) 83.7% (82.6-84.8) 70.6% (65.2-75.5) 80.5% (79.4-81.4) 80.0% (79.0-81.0)
No children 79.6% (76.3-82.5) 85.0% (83.3-86.6) 83.6% (82.0-85.0) 65.6% (58.6-71.9) 81.2% (79.4-82.8) 79.6% (77.9-81.3)
Post-graduate training
No 81.2% (79.1-83.1) 84.6% (83.6-85.6) 83.8% (82.8-84.6) 69.8% (65.3-73.9) 80.6% (79.7-81.5) 80.0% (79.1-80.9)
Yes 82.1% (75.7-87.1) 82.8% (79.0-86.1) 82.5% (79.3-85.3) 61.3% (49.4-72.1) 81.2% (77.8-84.2) 78.8% (75.5-81.8)
Length of service (Recoded)
5 years or less 80.4% (75.5-84.5) 84.0% (81.4-86.3) 83.1% (80.8-85.1) 71.6% (62.3-79.3) 83.1% (79.9-86.0) 81.3% (78.3-84.0)
6-10 years 75.2% (68.8-80.7) 82.5% (79.2-85.3) 80.6% (77.7-83.2) 62.2% (50.1-73.0) 79.6% (76.7-82.2) 78.2% (75.3-80.8)
More than 10 years 82.7% (80.4-84.8) 84.9% (83.7-86.0) 84.3% (83.3-85.3) 69.1% (63.8-73.9) 80.6% (79.6-81.5) 80.0% (79.1-80.9)
Healthcare setting (Recoded)
Outpatient care 79.2% (76.0-82.1) 83.2% (81.9-84.4) 82.4% (81.3-83.6) 74.7% (64.3-83.0) 80.1% (78.7-81.3) 79.9% (78.6-81.2)
In-hospital care 84.6% (81.8-87.1) 87.9% (86.1-89.5) 86.8% (85.3-88.2) 62.7% (50.0-73.9) 81.2% (79.8-82.5) 80.9% (79.5-82.2)
Emergencies 76.1% (69.9-81.5) 82.6% (78.0-86.4) 79.9% (76.3-83.1) 68.0% (62.9-72.7) 80.8% (78.4-82.9) 77.7% (75.5-79.7)
Proximity to combat areas and occupied territories
No conflict zone 80.6% (78.5-82.6) 83.8% (82.6-84.9) 82.9% (81.9-83.9) 70.2% (65.5-74.5) 80.4% (79.4-81.3) 79.8% (78.8-80.7)
Conflict zone 85.1% (79.8-89.2) 87.5% (85.2-89.5) 87.0% (84.9-88.8) 62.4% (52.6-71.3) 81.8% (79.8-83.7) 80.5% (78.5-82.3)
Unweighted Prevalence (95% CI)
tbl_purpose_u
Purpose in work (Unweighted)
Doctor
Nurse
Male
(N = 1,806)
Female
(N = 5,558)
Overall
(N = 7,376)
Male
(N = 587)
Female
(N = 8,906)
Overall
(N = 9,519)
Overall
Overall 87.7% (86.0-89.1) 90.7% (89.9-91.5) 89.9% (89.2-90.6) 84.7% (81.4-87.4) 89.2% (88.5-89.8) 88.9% (88.3-89.5)
Age groups (Recoded)
20-30 87.2% (83.0-90.5) 87.8% (85.3-89.9) 87.6% (85.6-89.4) 76.6% (69.8-82.3) 89.1% (87.3-90.8) 87.5% (85.7-89.2)
31-45 84.3% (80.9-87.1) 89.5% (88.0-90.8) 88.2% (86.8-89.5) 90.3% (84.8-94.0) 87.1% (85.9-88.2) 87.2% (86.1-88.3)
46-55 89.7% (86.0-92.6) 90.5% (88.6-92.1) 90.3% (88.7-91.7) 85.6% (78.4-90.8) 90.0% (88.8-91.1) 89.8% (88.6-90.8)
Over 55 89.9% (87.1-92.2) 93.7% (92.4-94.8) 92.7% (91.5-93.7) 89.3% (79.5-95.0) 92.6% (91.1-93.8) 92.5% (91.1-93.7)
Relationship status
No partner 84.8% (81.1-87.9) 90.7% (89.3-91.9) 89.6% (88.3-90.7) 81.0% (75.0-85.9) 89.8% (88.7-90.9) 89.2% (88.1-90.3)
Has a partner 88.6% (86.7-90.2) 90.8% (89.7-91.7) 90.1% (89.2-90.9) 86.8% (82.8-90.0) 88.9% (88.1-89.7) 88.8% (88.0-89.6)
Having children in the household
Has children 88.6% (86.5-90.4) 90.9% (89.9-91.8) 90.3% (89.4-91.1) 87.4% (83.4-90.6) 89.3% (88.5-90.0) 89.2% (88.4-89.9)
No children 86.1% (83.2-88.5) 90.5% (89.1-91.7) 89.3% (88.1-90.5) 80.4% (74.6-85.2) 89.1% (87.7-90.3) 88.2% (86.9-89.5)
Post-graduate training
No 87.4% (85.6-89.0) 90.6% (89.8-91.4) 89.8% (89.1-90.5) 86.1% (82.8-88.9) 89.0% (88.3-89.7) 88.9% (88.2-89.5)
Yes 89.7% (84.4-93.5) 91.6% (88.6-93.9) 90.9% (88.5-93.0) 74.7% (63.1-83.7) 91.4% (88.9-93.4) 89.7% (87.2-91.8)
Length of service (Recoded)
5 years or less 87.8% (83.7-91.1) 88.6% (86.4-90.5) 88.4% (86.5-90.1) 80.8% (72.6-87.1) 90.7% (88.2-92.7) 89.2% (86.8-91.2)
6-10 years 81.7% (75.9-86.4) 89.0% (86.3-91.3) 87.1% (84.7-89.2) 77.9% (67.4-85.9) 88.4% (86.1-90.4) 87.5% (85.3-89.5)
More than 10 years 88.7% (86.8-90.4) 91.5% (90.6-92.4) 90.8% (90.0-91.6) 87.4% (83.5-90.5) 89.1% (88.4-89.8) 89.1% (88.3-89.7)
Healthcare setting (Recoded)
Outpatient care 85.2% (82.5-87.6) 89.3% (88.2-90.3) 88.6% (87.6-89.5) 89.9% (81.8-94.8) 88.3% (87.2-89.3) 88.3% (87.3-89.3)
In-hospital care 90.1% (87.7-92.0) 94.1% (92.7-95.2) 92.7% (91.5-93.7) 82.1% (71.4-89.5) 90.4% (89.4-91.4) 90.3% (89.2-91.2)
Emergencies 87.0% (81.8-90.9) 90.1% (86.4-92.8) 88.7% (85.9-91.1) 83.9% (79.9-87.3) 88.8% (87.0-90.4) 87.6% (86.0-89.1)
Proximity to combat areas and occupied territories
No conflict zone 87.3% (85.6-88.9) 90.3% (89.4-91.2) 89.5% (88.7-90.3) 86.3% (82.7-89.2) 89.0% (88.2-89.7) 88.8% (88.1-89.5)
Conflict zone 89.5% (84.9-92.8) 92.5% (90.7-94.0) 91.9% (90.2-93.3) 78.1% (69.2-85.1) 90.2% (88.7-91.6) 89.4% (87.9-90.8)
Unweighted Prevalence (95% CI)
table_all_exposures_u <- gen_exp_tbl_unweighted(ds_ua, exposures)

gtsave(table_all_exposures_u, "out/tables/all_exp_tbl_unweighted.docx")

table_all_exposures_u
Exposure
Doctor
Nurse
Male
(N = 2,496)
Female
(N = 7,662)
Overall
(N = 10,188)
Male
(N = 835)
Female
(N = 12,744)
Overall
(N = 13,617)
Risk factor
Bullying 24.5% (22.7-26.3) 27.4% (26.3-28.5) 26.7% (25.8-27.6) 22.0% (19.0-25.2) 18.1% (17.4-18.8) 18.3% (17.6-19.0)
Sexual Harassment 8.2% (7.1-9.5) 9.8% (9.1-10.5) 9.4% (8.8-10.1) 8.8% (6.9-11.2) 6.8% (6.3-7.3) 6.9% (6.4-7.4)
Violent threats 27.2% (25.4-29.1) 17.6% (16.7-18.6) 20.1% (19.2-20.9) 29.0% (25.7-32.5) 10.2% (9.7-10.8) 11.4% (10.8-12.0)
Physical violence 5.5% (4.6-6.6) 2.5% (2.2-2.9) 3.3% (2.9-3.7) 10.9% (8.8-13.5) 3.1% (2.8-3.5) 3.6% (3.3-4.0)
Protective factor
Colleague support 58.7% (56.7-60.8) 59.8% (58.7-61.0) 59.5% (58.5-60.5) 54.6% (50.9-58.2) 58.3% (57.3-59.2) 58.1% (57.2-58.9)
Support from superiors 49.5% (47.5-51.6) 52.7% (51.5-53.9) 51.8% (50.8-52.9) 48.7% (45.0-52.4) 51.2% (50.3-52.2) 51.1% (50.2-52.0)
Meaning in work 81.3% (79.3-83.1) 84.5% (83.4-85.4) 83.6% (82.7-84.5) 68.6% (64.4-72.5) 80.6% (79.8-81.5) 79.9% (79.1-80.7)
Purpose in work 87.7% (86.0-89.1) 90.7% (89.9-91.5) 89.9% (89.2-90.6) 84.7% (81.4-87.4) 89.2% (88.5-89.8) 88.9% (88.3-89.5)
Unweighted Prevalence (95% CI)
table_all_outcomes_u <- gen_out_tbl_unweighted(ds_ua, outcomes)

gtsave(table_all_outcomes_u, "out/tables/all_out_tbl_unweighted.docx")

table_all_outcomes_u
Outcome
Doctor
Nurse
Male
(N = 2,496)
Female
(N = 7,662)
Overall
(N = 10,188)
Male
(N = 835)
Female
(N = 12,744)
Overall
(N = 13,617)
Probable Depression (PHQ-9) 33.8% (31.8-35.9) 35.5% (34.4-36.7) 35.1% (34.1-36.2) 27.5% (24.2-31.0) 22.4% (21.6-23.3) 22.7% (21.9-23.5)
Probable Anxiety (GAD-7) 21.7% (20.0-23.5) 25.7% (24.6-26.8) 24.7% (23.8-25.7) 16.3% (13.7-19.4) 16.6% (15.9-17.3) 16.6% (15.9-17.3)
Passive suicide thoughts (Item 9 of PHQ-9) 15.2% (13.7-16.8) 11.4% (10.6-12.2) 12.3% (11.7-13.1) 12.6% (10.3-15.4) 8.0% (7.5-8.5) 8.3% (7.8-8.8)
Unweighted Prevalence (95% CI). PHQ-9: 9-item Patient Health Questionnaire, a cut-off score ≥ 10 is defined for detecting probable depression. GAD-7: 7 item anxiety scale, a cut-off score ≥ 10 is defined for detecting probable anxiety. Any positive answer in the 9th item of the PHQ-9 is considered as having passive suicide thoughts.
reg_tbl <- 
  
  ds_ua |> 
  select(loc_en, work_2, scdm_2_rec) |>
  tbl_strata(
    strata = "work_2",
    ~ tbl_summary(., 
                  by = "scdm_2_rec",
                  label = list(loc_en = "Region")) |> 
      add_overall()
    ) |> 
  as_gt()
## 30 missing rows in the "scdm_2_rec" column have been removed.
## 38 missing rows in the "scdm_2_rec" column have been removed.
reg_tbl
Characteristic
Doctor
Nurse
Overall
N = 10,158
1
Female
N = 7,662
1
Male
N = 2,496
1
Overall
N = 13,579
1
Female
N = 12,744
1
Male
N = 835
1
Region





    Cherkasy Oblast 394 (3.9%) 279 (3.6%) 115 (4.6%) 650 (4.8%) 632 (5.0%) 18 (2.2%)
    Chernihiv Oblast 311 (3.1%) 250 (3.3%) 61 (2.4%) 675 (5.0%) 631 (5.0%) 44 (5.3%)
    Chernivtsi Oblast 65 (0.6%) 47 (0.6%) 18 (0.7%) 65 (0.5%) 64 (0.5%) 1 (0.1%)
    Crimea 0 (0%) 0 (0%) 0 (0%) 0 (0%) 0 (0%) 0 (0%)
    Dnipropetrovsk Oblast 1,123 (11%) 799 (10%) 324 (13%) 1,874 (14%) 1,651 (13%) 223 (27%)
    Donetsk Oblast 42 (0.4%) 29 (0.4%) 13 (0.5%) 76 (0.6%) 72 (0.6%) 4 (0.5%)
    Ivano-Frankivsk Oblast 504 (5.0%) 355 (4.6%) 149 (6.0%) 591 (4.4%) 570 (4.5%) 21 (2.5%)
    Kharkiv Oblast 766 (7.5%) 602 (7.9%) 164 (6.6%) 1,159 (8.5%) 1,073 (8.4%) 86 (10%)
    Kherson Oblast 82 (0.8%) 61 (0.8%) 21 (0.8%) 131 (1.0%) 129 (1.0%) 2 (0.2%)
    Khmelnytskyi Oblast 346 (3.4%) 216 (2.8%) 130 (5.2%) 401 (3.0%) 392 (3.1%) 9 (1.1%)
    Kirovohrad Oblast 548 (5.4%) 419 (5.5%) 129 (5.2%) 628 (4.6%) 595 (4.7%) 33 (4.0%)
    Kyiv City 456 (4.5%) 347 (4.5%) 109 (4.4%) 304 (2.2%) 271 (2.1%) 33 (4.0%)
    Kyiv Oblast 271 (2.7%) 215 (2.8%) 56 (2.2%) 205 (1.5%) 196 (1.5%) 9 (1.1%)
    Luhansk Oblast 16 (0.2%) 13 (0.2%) 3 (0.1%) 6 (<0.1%) 6 (<0.1%) 0 (0%)
    Lviv Oblast 1,331 (13%) 1,028 (13%) 303 (12%) 1,476 (11%) 1,438 (11%) 38 (4.6%)
    Mykolaiv Oblast 226 (2.2%) 173 (2.3%) 53 (2.1%) 436 (3.2%) 400 (3.1%) 36 (4.3%)
    Odesa Oblast 565 (5.6%) 435 (5.7%) 130 (5.2%) 853 (6.3%) 724 (5.7%) 129 (15%)
    Poltava Oblast 483 (4.8%) 404 (5.3%) 79 (3.2%) 700 (5.2%) 682 (5.4%) 18 (2.2%)
    Rivne Oblast 193 (1.9%) 148 (1.9%) 45 (1.8%) 208 (1.5%) 204 (1.6%) 4 (0.5%)
    Sumy Oblast 202 (2.0%) 163 (2.1%) 39 (1.6%) 275 (2.0%) 267 (2.1%) 8 (1.0%)
    Ternopil Oblast 551 (5.4%) 399 (5.2%) 152 (6.1%) 968 (7.1%) 931 (7.3%) 37 (4.4%)
    Vinnytsia Oblast 143 (1.4%) 118 (1.5%) 25 (1.0%) 215 (1.6%) 211 (1.7%) 4 (0.5%)
    Volyn Oblast 468 (4.6%) 353 (4.6%) 115 (4.6%) 607 (4.5%) 582 (4.6%) 25 (3.0%)
    Zakarpattia Oblast 235 (2.3%) 152 (2.0%) 83 (3.3%) 178 (1.3%) 154 (1.2%) 24 (2.9%)
    Zaporizhzhia Oblast 299 (2.9%) 240 (3.1%) 59 (2.4%) 226 (1.7%) 221 (1.7%) 5 (0.6%)
    Zhytomyr Oblast 538 (5.3%) 417 (5.4%) 121 (4.8%) 672 (4.9%) 648 (5.1%) 24 (2.9%)
1 n (%)
gtsave(reg_tbl, "out/tables/tbl_ukr_reg.docx")
vio_exp_agg <- c("work_30_dic", "work_31_dic", "work_32_dic",
                 "work_33_dic")

prot_fac_agg <- c("work_21_dic", "work_22_dic", "wb_wami_1_dic",
                  "wb_wami_2_dic")

out_prev_agg <- c("phq_co", "gad_co", "suic_idea")

exp_reg <-
  
  ds_ua |> 
  group_by(loc_en) |> 
  summarise(
    across(
      all_of(vio_exp_agg),
      ~ mean(. == "Yes", na.rm = TRUE)
    )
  ) |> 
  add_row(tibble_row(loc_en = "Crimea")) |> 
  left_join(ua_reg_conflict |> select(loc_3, loc_en, fips_code),
            by = "loc_en")

exp_reg
## # A tibble: 26 × 7
##    loc_en        work_30_dic work_31_dic work_32_dic work_33_dic loc_3 fips_code
##    <chr>               <dbl>       <dbl>       <dbl>       <dbl> <fct> <chr>    
##  1 Cherkasy Obl…      0.113       0.171       0.0432       0.253 Черк… UP01     
##  2 Chernihiv Ob…      0.0641      0.160       0.0355       0.232 Черн… UP02     
##  3 Chernivtsi O…      0.0667      0.143       0.0288       0.269 Черн… UP03     
##  4 Dnipropetrov…      0.0809      0.199       0.0594       0.194 Дніп… UP04     
##  5 Donetsk Obla…      0.0550      0.0926      0.0278       0.148 Доне… UP05     
##  6 Ivano-Franki…      0.0825      0.126       0.0251       0.248 Іван… UP06     
##  7 Kharkiv Obla…      0.0828      0.127       0.0352       0.199 Харк… UP07     
##  8 Kherson Obla…      0.0659      0.120       0.0180       0.156 Херс… UP08     
##  9 Khmelnytskyi…      0.116       0.188       0.0569       0.268 Хмел… UP09     
## 10 Kirovohrad O…      0.0847      0.169       0.0297       0.245 Кіро… UP10     
## # ℹ 16 more rows
saveRDS(exp_reg, "out/dataframes/exposure_regions.rds")
  
out_reg <-
  
  ds_ua |> 
  group_by(loc_en) |> 
  summarise(
    across(
      all_of(out_prev_agg),
      ~ mean(. == 1, na.rm = TRUE)
    )
  ) |> 
  add_row(tibble_row(loc_en = "Crimea"))|> 
  left_join(ua_reg_conflict |> select(loc_3, loc_en, fips_code),
            by = "loc_en")

out_reg
## # A tibble: 26 × 6
##    loc_en                 phq_co gad_co suic_idea loc_3                fips_code
##    <chr>                   <dbl>  <dbl>     <dbl> <fct>                <chr>    
##  1 Cherkasy Oblast         0.309  0.216    0.117  Черкаська Область    UP01     
##  2 Chernihiv Oblast        0.325  0.244    0.120  Чернігівська Область UP02     
##  3 Chernivtsi Oblast       0.218  0.149    0.0990 Чернівецька Область  UP03     
##  4 Dnipropetrovsk Oblast   0.274  0.198    0.101  Дніпропетровська Об… UP04     
##  5 Donetsk Oblast          0.264  0.189    0.104  Донецька Область     UP05     
##  6 Ivano-Frankivsk Oblast  0.266  0.192    0.0991 Івано-Франківська О… UP06     
##  7 Kharkiv Oblast          0.270  0.204    0.0982 Харківська Область   UP07     
##  8 Kherson Oblast          0.276  0.220    0.0848 Херсонська Область   UP08     
##  9 Khmelnytskyi Oblast     0.327  0.221    0.114  Хмельницька Область  UP09     
## 10 Kirovohrad Oblast       0.266  0.204    0.106  Кіровоградська Обла… UP10     
## # ℹ 16 more rows
saveRDS(out_reg, "out/dataframes/outcome_regions.rds")

Generalized Linear Models with Multilevel variables

Run models

# define covariates
covariate_map <- list(
  "peer" = c("conflict", "scdm_1_rec", "scdm_2_rec", "work_2", "work_5_rec",
             "work_3_rec", "work_1"),
  
  "viol" = c("conflict", "scdm_1_rec", "scdm_2_rec", "work_2", "work_5_rec"),
  
  "har_bul" = c("conflict", "scdm_1_rec", "scdm_2_rec", "work_2", "work_1",
                "work_3_rec", "work_5_rec"),
  
  "meanpur" = c("conflict", "scdm_1_rec", "scdm_2_rec", "work_2",
                "work_5_rec", "work_3_rec", "work_1", "scdm_4_dic",
                "scdm_5_dic"),
  
  "structure" = c("conflict", "scdm_1_rec", "scdm_2_rec", "work_2")
)

analysis_plan <- tribble(
  ~Exposure,     ~Covar_Key,
  "work_21_dic", "peer",
  "work_22_dic", "peer",
  "work_31_dic", "viol",
  "work_32_dic", "viol",
  "work_30_dic", "har_bul",
  "work_33_dic", "har_bul",
  "wb_wami_1_dic", "meanpur",
  "wb_wami_2_dic", "meanpur"
)

outcomes_map <- tribble(
  ~Outcome,    ~Family,
  "phq_co",    "poisson",
  "gad_co",    "poisson",
  "suic_idea",    "poisson",
)

# Define stratification of models
profs <- c("Doctor", "Nurse")

# Generate exposure-outcome binomials
tasks <- expand_grid(
  out_row = outcomes_map,
  exp_row = analysis_plan,
  profession = profs
) |> 
  tidyr::unpack(cols = c(out_row, exp_row))


all_runs_list <- pmap(list(
  tasks$Outcome,
  tasks$Family,
  tasks$Exposure,
  tasks$Covar_Key,
  tasks$profession
), function(outcome, family, exposure, cov_key, prof) {
  
  message(paste("Processing:", outcome, "x", exposure, "in", prof))
  
  res_crude <- run_crude_glm(
    data = ds_ua, 
    outcome_var = outcome,
    exposure_var = exposure, 
    profession = prof,
    cluster_var = "loc_3", 
    family_type = family,
    )

  

  res_str <- run_glm_adj(
    data = ds_ua, 
    outcome_var = outcome, 
    exposure_var = exposure,
    confounder_list = covariate_map[["structure"]], 
    profession = prof,
    cluster_var = "loc_3", 
    family_type = family, 
    model_label = "Partially adjusted"
    )
  
  #look up for specific covariate list
  specific_covars <- covariate_map[[cov_key]]
  
  res_adj <- run_glm_adj(
    data = ds_ua, 
    outcome_var = outcome, 
    exposure_var = exposure,
    confounder_list = specific_covars, 
    profession = prof,
    cluster_var = "loc_3", 
    family_type = family, 
    model_label = "Fully adjusted"
    )
  
  
  # Combine internally
  row_multilevel <- 
    
    bind_rows(
      res_crude$multilevel,
      res_str$multilevel,
      res_adj$multilevel
    )
  
  row_robust <- 
    
    bind_rows(
      res_crude$robust,
      res_str$robust,
      res_adj$robust
    )
  
  # return as clean pair
  return(list(
    multilevel = row_multilevel,
    robust     = row_robust
  ))
})
## Processing: phq_co x work_21_dic in Doctor
## Loading ML model: glm_dep_cols_doc_cr_ml.rds
## Loading Robust model: glm_dep_cols_doc_cr_rob.rds
## Loading ML model: glm_dep_cols_doc_str_ml.rds
## Loading Robust SE model: glm_dep_cols_doc_str_rob.rds
## Loading ML model: glm_dep_cols_doc_adj_ml.rds
## Loading Robust SE model: glm_dep_cols_doc_adj_rob.rds
## Processing: phq_co x work_21_dic in Nurse
## Loading ML model: glm_dep_cols_nur_cr_ml.rds
## Loading Robust model: glm_dep_cols_nur_cr_rob.rds
## Loading ML model: glm_dep_cols_nur_str_ml.rds
## Loading Robust SE model: glm_dep_cols_nur_str_rob.rds
## Loading ML model: glm_dep_cols_nur_adj_ml.rds
## Loading Robust SE model: glm_dep_cols_nur_adj_rob.rds
## Processing: phq_co x work_22_dic in Doctor
## Loading ML model: glm_dep_sup_doc_cr_ml.rds
## Loading Robust model: glm_dep_sup_doc_cr_rob.rds
## Loading ML model: glm_dep_sup_doc_str_ml.rds
## Loading Robust SE model: glm_dep_sup_doc_str_rob.rds
## Loading ML model: glm_dep_sup_doc_adj_ml.rds
## Loading Robust SE model: glm_dep_sup_doc_adj_rob.rds
## Processing: phq_co x work_22_dic in Nurse
## Loading ML model: glm_dep_sup_nur_cr_ml.rds
## Loading Robust model: glm_dep_sup_nur_cr_rob.rds
## Loading ML model: glm_dep_sup_nur_str_ml.rds
## Loading Robust SE model: glm_dep_sup_nur_str_rob.rds
## Loading ML model: glm_dep_sup_nur_adj_ml.rds
## Loading Robust SE model: glm_dep_sup_nur_adj_rob.rds
## Processing: phq_co x work_31_dic in Doctor
## Loading ML model: glm_dep_threats_doc_cr_ml.rds
## Loading Robust model: glm_dep_threats_doc_cr_rob.rds
## Loading ML model: glm_dep_threats_doc_str_ml.rds
## Loading Robust SE model: glm_dep_threats_doc_str_rob.rds
## Loading ML model: glm_dep_threats_doc_adj_ml.rds
## Loading Robust SE model: glm_dep_threats_doc_adj_rob.rds
## Processing: phq_co x work_31_dic in Nurse
## Loading ML model: glm_dep_threats_nur_cr_ml.rds
## Loading Robust model: glm_dep_threats_nur_cr_rob.rds
## Loading ML model: glm_dep_threats_nur_str_ml.rds
## Loading Robust SE model: glm_dep_threats_nur_str_rob.rds
## Loading ML model: glm_dep_threats_nur_adj_ml.rds
## Loading Robust SE model: glm_dep_threats_nur_adj_rob.rds
## Processing: phq_co x work_32_dic in Doctor
## Loading ML model: glm_dep_viol_doc_cr_ml.rds
## Loading Robust model: glm_dep_viol_doc_cr_rob.rds
## Loading ML model: glm_dep_viol_doc_str_ml.rds
## Loading Robust SE model: glm_dep_viol_doc_str_rob.rds
## Loading ML model: glm_dep_viol_doc_adj_ml.rds
## Loading Robust SE model: glm_dep_viol_doc_adj_rob.rds
## Processing: phq_co x work_32_dic in Nurse
## Loading ML model: glm_dep_viol_nur_cr_ml.rds
## Loading Robust model: glm_dep_viol_nur_cr_rob.rds
## Loading ML model: glm_dep_viol_nur_str_ml.rds
## Loading Robust SE model: glm_dep_viol_nur_str_rob.rds
## Loading ML model: glm_dep_viol_nur_adj_ml.rds
## Loading Robust SE model: glm_dep_viol_nur_adj_rob.rds
## Processing: phq_co x work_30_dic in Doctor
## Loading ML model: glm_dep_har_doc_cr_ml.rds
## Loading Robust model: glm_dep_har_doc_cr_rob.rds
## Loading ML model: glm_dep_har_doc_str_ml.rds
## Loading Robust SE model: glm_dep_har_doc_str_rob.rds
## Loading ML model: glm_dep_har_doc_adj_ml.rds
## Loading Robust SE model: glm_dep_har_doc_adj_rob.rds
## Processing: phq_co x work_30_dic in Nurse
## Loading ML model: glm_dep_har_nur_cr_ml.rds
## Loading Robust model: glm_dep_har_nur_cr_rob.rds
## Loading ML model: glm_dep_har_nur_str_ml.rds
## Loading Robust SE model: glm_dep_har_nur_str_rob.rds
## Loading ML model: glm_dep_har_nur_adj_ml.rds
## Loading Robust SE model: glm_dep_har_nur_adj_rob.rds
## Processing: phq_co x work_33_dic in Doctor
## Loading ML model: glm_dep_bul_doc_cr_ml.rds
## Loading Robust model: glm_dep_bul_doc_cr_rob.rds
## Loading ML model: glm_dep_bul_doc_str_ml.rds
## Loading Robust SE model: glm_dep_bul_doc_str_rob.rds
## Loading ML model: glm_dep_bul_doc_adj_ml.rds
## Loading Robust SE model: glm_dep_bul_doc_adj_rob.rds
## Processing: phq_co x work_33_dic in Nurse
## Loading ML model: glm_dep_bul_nur_cr_ml.rds
## Loading Robust model: glm_dep_bul_nur_cr_rob.rds
## Loading ML model: glm_dep_bul_nur_str_ml.rds
## Loading Robust SE model: glm_dep_bul_nur_str_rob.rds
## Loading ML model: glm_dep_bul_nur_adj_ml.rds
## Loading Robust SE model: glm_dep_bul_nur_adj_rob.rds
## Processing: phq_co x wb_wami_1_dic in Doctor
## Loading ML model: glm_dep_mean_doc_cr_ml.rds
## Loading Robust model: glm_dep_mean_doc_cr_rob.rds
## Loading ML model: glm_dep_mean_doc_str_ml.rds
## Loading Robust SE model: glm_dep_mean_doc_str_rob.rds
## Loading ML model: glm_dep_mean_doc_adj_ml.rds
## Loading Robust SE model: glm_dep_mean_doc_adj_rob.rds
## Processing: phq_co x wb_wami_1_dic in Nurse
## Loading ML model: glm_dep_mean_nur_cr_ml.rds
## Loading Robust model: glm_dep_mean_nur_cr_rob.rds
## Loading ML model: glm_dep_mean_nur_str_ml.rds
## Loading Robust SE model: glm_dep_mean_nur_str_rob.rds
## Loading ML model: glm_dep_mean_nur_adj_ml.rds
## Loading Robust SE model: glm_dep_mean_nur_adj_rob.rds
## Processing: phq_co x wb_wami_2_dic in Doctor
## Loading ML model: glm_dep_purp_doc_cr_ml.rds
## Loading Robust model: glm_dep_purp_doc_cr_rob.rds
## Loading ML model: glm_dep_purp_doc_str_ml.rds
## Loading Robust SE model: glm_dep_purp_doc_str_rob.rds
## Loading ML model: glm_dep_purp_doc_adj_ml.rds
## Loading Robust SE model: glm_dep_purp_doc_adj_rob.rds
## Processing: phq_co x wb_wami_2_dic in Nurse
## Loading ML model: glm_dep_purp_nur_cr_ml.rds
## Loading Robust model: glm_dep_purp_nur_cr_rob.rds
## Loading ML model: glm_dep_purp_nur_str_ml.rds
## Loading Robust SE model: glm_dep_purp_nur_str_rob.rds
## Loading ML model: glm_dep_purp_nur_adj_ml.rds
## Loading Robust SE model: glm_dep_purp_nur_adj_rob.rds
## Processing: gad_co x work_21_dic in Doctor
## Loading ML model: glm_anx_cols_doc_cr_ml.rds
## Loading Robust model: glm_anx_cols_doc_cr_rob.rds
## Loading ML model: glm_anx_cols_doc_str_ml.rds
## Loading Robust SE model: glm_anx_cols_doc_str_rob.rds
## Loading ML model: glm_anx_cols_doc_adj_ml.rds
## Loading Robust SE model: glm_anx_cols_doc_adj_rob.rds
## Processing: gad_co x work_21_dic in Nurse
## Loading ML model: glm_anx_cols_nur_cr_ml.rds
## Loading Robust model: glm_anx_cols_nur_cr_rob.rds
## Loading ML model: glm_anx_cols_nur_str_ml.rds
## Loading Robust SE model: glm_anx_cols_nur_str_rob.rds
## Loading ML model: glm_anx_cols_nur_adj_ml.rds
## Loading Robust SE model: glm_anx_cols_nur_adj_rob.rds
## Processing: gad_co x work_22_dic in Doctor
## Loading ML model: glm_anx_sup_doc_cr_ml.rds
## Loading Robust model: glm_anx_sup_doc_cr_rob.rds
## Loading ML model: glm_anx_sup_doc_str_ml.rds
## Loading Robust SE model: glm_anx_sup_doc_str_rob.rds
## Loading ML model: glm_anx_sup_doc_adj_ml.rds
## Loading Robust SE model: glm_anx_sup_doc_adj_rob.rds
## Processing: gad_co x work_22_dic in Nurse
## Loading ML model: glm_anx_sup_nur_cr_ml.rds
## Loading Robust model: glm_anx_sup_nur_cr_rob.rds
## Loading ML model: glm_anx_sup_nur_str_ml.rds
## Loading Robust SE model: glm_anx_sup_nur_str_rob.rds
## Loading ML model: glm_anx_sup_nur_adj_ml.rds
## Loading Robust SE model: glm_anx_sup_nur_adj_rob.rds
## Processing: gad_co x work_31_dic in Doctor
## Loading ML model: glm_anx_threats_doc_cr_ml.rds
## Loading Robust model: glm_anx_threats_doc_cr_rob.rds
## Loading ML model: glm_anx_threats_doc_str_ml.rds
## Loading Robust SE model: glm_anx_threats_doc_str_rob.rds
## Loading ML model: glm_anx_threats_doc_adj_ml.rds
## Loading Robust SE model: glm_anx_threats_doc_adj_rob.rds
## Processing: gad_co x work_31_dic in Nurse
## Loading ML model: glm_anx_threats_nur_cr_ml.rds
## Loading Robust model: glm_anx_threats_nur_cr_rob.rds
## Loading ML model: glm_anx_threats_nur_str_ml.rds
## Loading Robust SE model: glm_anx_threats_nur_str_rob.rds
## Loading ML model: glm_anx_threats_nur_adj_ml.rds
## Loading Robust SE model: glm_anx_threats_nur_adj_rob.rds
## Processing: gad_co x work_32_dic in Doctor
## Loading ML model: glm_anx_viol_doc_cr_ml.rds
## Loading Robust model: glm_anx_viol_doc_cr_rob.rds
## Loading ML model: glm_anx_viol_doc_str_ml.rds
## Loading Robust SE model: glm_anx_viol_doc_str_rob.rds
## Loading ML model: glm_anx_viol_doc_adj_ml.rds
## Loading Robust SE model: glm_anx_viol_doc_adj_rob.rds
## Processing: gad_co x work_32_dic in Nurse
## Loading ML model: glm_anx_viol_nur_cr_ml.rds
## Loading Robust model: glm_anx_viol_nur_cr_rob.rds
## Loading ML model: glm_anx_viol_nur_str_ml.rds
## Loading Robust SE model: glm_anx_viol_nur_str_rob.rds
## Loading ML model: glm_anx_viol_nur_adj_ml.rds
## Loading Robust SE model: glm_anx_viol_nur_adj_rob.rds
## Processing: gad_co x work_30_dic in Doctor
## Loading ML model: glm_anx_har_doc_cr_ml.rds
## Loading Robust model: glm_anx_har_doc_cr_rob.rds
## Loading ML model: glm_anx_har_doc_str_ml.rds
## Loading Robust SE model: glm_anx_har_doc_str_rob.rds
## Loading ML model: glm_anx_har_doc_adj_ml.rds
## Loading Robust SE model: glm_anx_har_doc_adj_rob.rds
## Processing: gad_co x work_30_dic in Nurse
## Loading ML model: glm_anx_har_nur_cr_ml.rds
## Loading Robust model: glm_anx_har_nur_cr_rob.rds
## Loading ML model: glm_anx_har_nur_str_ml.rds
## Loading Robust SE model: glm_anx_har_nur_str_rob.rds
## Loading ML model: glm_anx_har_nur_adj_ml.rds
## Loading Robust SE model: glm_anx_har_nur_adj_rob.rds
## Processing: gad_co x work_33_dic in Doctor
## Loading ML model: glm_anx_bul_doc_cr_ml.rds
## Loading Robust model: glm_anx_bul_doc_cr_rob.rds
## Loading ML model: glm_anx_bul_doc_str_ml.rds
## Loading Robust SE model: glm_anx_bul_doc_str_rob.rds
## Loading ML model: glm_anx_bul_doc_adj_ml.rds
## Loading Robust SE model: glm_anx_bul_doc_adj_rob.rds
## Processing: gad_co x work_33_dic in Nurse
## Loading ML model: glm_anx_bul_nur_cr_ml.rds
## Loading Robust model: glm_anx_bul_nur_cr_rob.rds
## Loading ML model: glm_anx_bul_nur_str_ml.rds
## Loading Robust SE model: glm_anx_bul_nur_str_rob.rds
## Loading ML model: glm_anx_bul_nur_adj_ml.rds
## Loading Robust SE model: glm_anx_bul_nur_adj_rob.rds
## Processing: gad_co x wb_wami_1_dic in Doctor
## Loading ML model: glm_anx_mean_doc_cr_ml.rds
## Loading Robust model: glm_anx_mean_doc_cr_rob.rds
## Loading ML model: glm_anx_mean_doc_str_ml.rds
## Loading Robust SE model: glm_anx_mean_doc_str_rob.rds
## Loading ML model: glm_anx_mean_doc_adj_ml.rds
## Loading Robust SE model: glm_anx_mean_doc_adj_rob.rds
## Processing: gad_co x wb_wami_1_dic in Nurse
## Loading ML model: glm_anx_mean_nur_cr_ml.rds
## Loading Robust model: glm_anx_mean_nur_cr_rob.rds
## Loading ML model: glm_anx_mean_nur_str_ml.rds
## Loading Robust SE model: glm_anx_mean_nur_str_rob.rds
## Loading ML model: glm_anx_mean_nur_adj_ml.rds
## Loading Robust SE model: glm_anx_mean_nur_adj_rob.rds
## Processing: gad_co x wb_wami_2_dic in Doctor
## Loading ML model: glm_anx_purp_doc_cr_ml.rds
## Loading Robust model: glm_anx_purp_doc_cr_rob.rds
## Loading ML model: glm_anx_purp_doc_str_ml.rds
## Loading Robust SE model: glm_anx_purp_doc_str_rob.rds
## Loading ML model: glm_anx_purp_doc_adj_ml.rds
## Loading Robust SE model: glm_anx_purp_doc_adj_rob.rds
## Processing: gad_co x wb_wami_2_dic in Nurse
## Loading ML model: glm_anx_purp_nur_cr_ml.rds
## Loading Robust model: glm_anx_purp_nur_cr_rob.rds
## Loading ML model: glm_anx_purp_nur_str_ml.rds
## Loading Robust SE model: glm_anx_purp_nur_str_rob.rds
## Loading ML model: glm_anx_purp_nur_adj_ml.rds
## Loading Robust SE model: glm_anx_purp_nur_adj_rob.rds
## Processing: suic_idea x work_21_dic in Doctor
## Loading ML model: glm_suic_cols_doc_cr_ml.rds
## Loading Robust model: glm_suic_cols_doc_cr_rob.rds
## Loading ML model: glm_suic_cols_doc_str_ml.rds
## Loading Robust SE model: glm_suic_cols_doc_str_rob.rds
## Loading ML model: glm_suic_cols_doc_adj_ml.rds
## Loading Robust SE model: glm_suic_cols_doc_adj_rob.rds
## Processing: suic_idea x work_21_dic in Nurse
## Loading ML model: glm_suic_cols_nur_cr_ml.rds
## Loading Robust model: glm_suic_cols_nur_cr_rob.rds
## Loading ML model: glm_suic_cols_nur_str_ml.rds
## Loading Robust SE model: glm_suic_cols_nur_str_rob.rds
## Loading ML model: glm_suic_cols_nur_adj_ml.rds
## Loading Robust SE model: glm_suic_cols_nur_adj_rob.rds
## Processing: suic_idea x work_22_dic in Doctor
## Loading ML model: glm_suic_sup_doc_cr_ml.rds
## Loading Robust model: glm_suic_sup_doc_cr_rob.rds
## Loading ML model: glm_suic_sup_doc_str_ml.rds
## Loading Robust SE model: glm_suic_sup_doc_str_rob.rds
## Loading ML model: glm_suic_sup_doc_adj_ml.rds
## Loading Robust SE model: glm_suic_sup_doc_adj_rob.rds
## Processing: suic_idea x work_22_dic in Nurse
## Loading ML model: glm_suic_sup_nur_cr_ml.rds
## Loading Robust model: glm_suic_sup_nur_cr_rob.rds
## Loading ML model: glm_suic_sup_nur_str_ml.rds
## Loading Robust SE model: glm_suic_sup_nur_str_rob.rds
## Loading ML model: glm_suic_sup_nur_adj_ml.rds
## Loading Robust SE model: glm_suic_sup_nur_adj_rob.rds
## Processing: suic_idea x work_31_dic in Doctor
## Loading ML model: glm_suic_threats_doc_cr_ml.rds
## Loading Robust model: glm_suic_threats_doc_cr_rob.rds
## Loading ML model: glm_suic_threats_doc_str_ml.rds
## Loading Robust SE model: glm_suic_threats_doc_str_rob.rds
## Loading ML model: glm_suic_threats_doc_adj_ml.rds
## Loading Robust SE model: glm_suic_threats_doc_adj_rob.rds
## Processing: suic_idea x work_31_dic in Nurse
## Loading ML model: glm_suic_threats_nur_cr_ml.rds
## Loading Robust model: glm_suic_threats_nur_cr_rob.rds
## Loading ML model: glm_suic_threats_nur_str_ml.rds
## Loading Robust SE model: glm_suic_threats_nur_str_rob.rds
## Loading ML model: glm_suic_threats_nur_adj_ml.rds
## Loading Robust SE model: glm_suic_threats_nur_adj_rob.rds
## Processing: suic_idea x work_32_dic in Doctor
## Loading ML model: glm_suic_viol_doc_cr_ml.rds
## Loading Robust model: glm_suic_viol_doc_cr_rob.rds
## Loading ML model: glm_suic_viol_doc_str_ml.rds
## Loading Robust SE model: glm_suic_viol_doc_str_rob.rds
## Loading ML model: glm_suic_viol_doc_adj_ml.rds
## Loading Robust SE model: glm_suic_viol_doc_adj_rob.rds
## Processing: suic_idea x work_32_dic in Nurse
## Loading ML model: glm_suic_viol_nur_cr_ml.rds
## Loading Robust model: glm_suic_viol_nur_cr_rob.rds
## Loading ML model: glm_suic_viol_nur_str_ml.rds
## Loading Robust SE model: glm_suic_viol_nur_str_rob.rds
## Loading ML model: glm_suic_viol_nur_adj_ml.rds
## Loading Robust SE model: glm_suic_viol_nur_adj_rob.rds
## Processing: suic_idea x work_30_dic in Doctor
## Loading ML model: glm_suic_har_doc_cr_ml.rds
## Loading Robust model: glm_suic_har_doc_cr_rob.rds
## Loading ML model: glm_suic_har_doc_str_ml.rds
## Loading Robust SE model: glm_suic_har_doc_str_rob.rds
## Loading ML model: glm_suic_har_doc_adj_ml.rds
## Loading Robust SE model: glm_suic_har_doc_adj_rob.rds
## Processing: suic_idea x work_30_dic in Nurse
## Loading ML model: glm_suic_har_nur_cr_ml.rds
## Loading Robust model: glm_suic_har_nur_cr_rob.rds
## Loading ML model: glm_suic_har_nur_str_ml.rds
## Loading Robust SE model: glm_suic_har_nur_str_rob.rds
## Loading ML model: glm_suic_har_nur_adj_ml.rds
## Loading Robust SE model: glm_suic_har_nur_adj_rob.rds
## Processing: suic_idea x work_33_dic in Doctor
## Loading ML model: glm_suic_bul_doc_cr_ml.rds
## Loading Robust model: glm_suic_bul_doc_cr_rob.rds
## Loading ML model: glm_suic_bul_doc_str_ml.rds
## Loading Robust SE model: glm_suic_bul_doc_str_rob.rds
## Loading ML model: glm_suic_bul_doc_adj_ml.rds
## Loading Robust SE model: glm_suic_bul_doc_adj_rob.rds
## Processing: suic_idea x work_33_dic in Nurse
## Loading ML model: glm_suic_bul_nur_cr_ml.rds
## Loading Robust model: glm_suic_bul_nur_cr_rob.rds
## Loading ML model: glm_suic_bul_nur_str_ml.rds
## Loading Robust SE model: glm_suic_bul_nur_str_rob.rds
## Loading ML model: glm_suic_bul_nur_adj_ml.rds
## Loading Robust SE model: glm_suic_bul_nur_adj_rob.rds
## Processing: suic_idea x wb_wami_1_dic in Doctor
## Loading ML model: glm_suic_mean_doc_cr_ml.rds
## Loading Robust model: glm_suic_mean_doc_cr_rob.rds
## Loading ML model: glm_suic_mean_doc_str_ml.rds
## Loading Robust SE model: glm_suic_mean_doc_str_rob.rds
## Loading ML model: glm_suic_mean_doc_adj_ml.rds
## Loading Robust SE model: glm_suic_mean_doc_adj_rob.rds
## Processing: suic_idea x wb_wami_1_dic in Nurse
## Loading ML model: glm_suic_mean_nur_cr_ml.rds
## Loading Robust model: glm_suic_mean_nur_cr_rob.rds
## Loading ML model: glm_suic_mean_nur_str_ml.rds
## Loading Robust SE model: glm_suic_mean_nur_str_rob.rds
## Loading ML model: glm_suic_mean_nur_adj_ml.rds
## Loading Robust SE model: glm_suic_mean_nur_adj_rob.rds
## Processing: suic_idea x wb_wami_2_dic in Doctor
## Loading ML model: glm_suic_purp_doc_cr_ml.rds
## Loading Robust model: glm_suic_purp_doc_cr_rob.rds
## Loading ML model: glm_suic_purp_doc_str_ml.rds
## Loading Robust SE model: glm_suic_purp_doc_str_rob.rds
## Loading ML model: glm_suic_purp_doc_adj_ml.rds
## Loading Robust SE model: glm_suic_purp_doc_adj_rob.rds
## Processing: suic_idea x wb_wami_2_dic in Nurse
## Loading ML model: glm_suic_purp_nur_cr_ml.rds
## Loading Robust model: glm_suic_purp_nur_cr_rob.rds
## Loading ML model: glm_suic_purp_nur_str_ml.rds
## Loading Robust SE model: glm_suic_purp_nur_str_rob.rds
## Loading ML model: glm_suic_purp_nur_adj_ml.rds
## Loading Robust SE model: glm_suic_purp_nur_adj_rob.rds
# Unzip and combine

glm_multilevel_df <- map_dfr(all_runs_list, "multilevel")

glm_robust_df <- map_dfr(all_runs_list, "robust")


# Save

saveRDS(glm_multilevel_df, "out/dataframes/glm_multilevel_df.rds")
writexl::write_xlsx(glm_multilevel_df,
                    "out/dataframes/glm_multilevel_df.xlsx")


saveRDS(glm_robust_df, "out/dataframes/glm_robust_df.rds")
writexl::write_xlsx(glm_robust_df, "out/dataframes/glm_robust_df.xlsx")

GLM results

# SE Ratios
glm_se_ratios <-
  
  glm_multilevel_df |>
  select(Outcome, Exposure, Profession, Adjustment, beta, PR, SE) |> 
  rename(`PR (ML)` = PR,
         `SE (ML)` = SE) |> 
  left_join(glm_robust_df |> 
              select(Outcome, Exposure, Profession, Adjustment, SE),
            by = c("Outcome", "Exposure", "Profession", "Adjustment")) |> 
  rename(`SE (Robust)` = SE) |> 
  mutate(`SE Ratio` = `SE (Robust)` / `SE (ML)`) |> 
  mutate(
    Exposure = case_when(
      Exposure == "work_21_dic" ~ "Colleague support",
      Exposure == "work_22_dic" ~ "Support from superiors",
      Exposure == "work_31_dic" ~ "Violent threats",
      Exposure == "work_32_dic" ~ "Physical violence",
      Exposure == "work_30_dic" ~ "Sexual Harassment",
      Exposure == "work_33_dic" ~ "Bullying",
      Exposure == "wb_wami_1_dic" ~ "Meaning in work",
      Exposure == "wb_wami_2_dic" ~ "Purpose in work",
      TRUE ~ Exposure),
    Outcome = case_when(
      Outcome == "phq_co" ~ "Depression",
      Outcome == "gad_co" ~ "Anxiety",
      Outcome == "suic_idea" ~ "Suicide thoughts",
      TRUE ~ Outcome
    )
  )

glm_se_ratios
## # A tibble: 144 × 9
##    Outcome    Exposure          Profession Adjustment   beta `PR (ML)` `SE (ML)`
##    <chr>      <chr>             <chr>      <chr>       <dbl>     <dbl>     <dbl>
##  1 Depression Colleague support Doctor     Crude      -0.458     0.633    0.0365
##  2 Depression Colleague support Doctor     Partially… -0.416     0.660    0.0366
##  3 Depression Colleague support Doctor     Fully adj… -0.419     0.658    0.0368
##  4 Depression Colleague support Nurse      Crude      -0.544     0.580    0.0402
##  5 Depression Colleague support Nurse      Partially… -0.519     0.595    0.0403
##  6 Depression Colleague support Nurse      Fully adj… -0.519     0.595    0.0404
##  7 Depression Support from sup… Doctor     Crude      -0.539     0.583    0.0375
##  8 Depression Support from sup… Doctor     Partially… -0.483     0.617    0.0376
##  9 Depression Support from sup… Doctor     Fully adj… -0.481     0.618    0.0378
## 10 Depression Support from sup… Nurse      Crude      -0.701     0.496    0.0422
## # ℹ 134 more rows
## # ℹ 2 more variables: `SE (Robust)` <dbl>, `SE Ratio` <dbl>
# Save

saveRDS(glm_se_ratios, "out/dataframes/glm_se_ratios_df.rds")
writexl::write_xlsx(glm_se_ratios, "out/dataframes/glm_se_ratios_df.xlsx")


# Results with ML estimator + SE robust

glm_results <-
  
  glm_multilevel_df |> 
  select(-c(model, N_Analysis, Risk_Unexp, Risk_Exp)) |> 
  mutate(
    Exposure = case_when(
      Exposure == "work_21_dic" ~ "Colleague support",
      Exposure == "work_22_dic" ~ "Support from superiors",
      Exposure == "work_31_dic" ~ "Violent threats",
      Exposure == "work_32_dic" ~ "Physical violence",
      Exposure == "work_30_dic" ~ "Sexual Harassment",
      Exposure == "work_33_dic" ~ "Bullying",
      Exposure == "wb_wami_1_dic" ~ "Meaning in work",
      Exposure == "wb_wami_2_dic" ~ "Purpose in work",
      TRUE ~ Exposure),
    Outcome = case_when(
      Outcome == "phq_co" ~ "Depression",
      Outcome == "gad_co" ~ "Anxiety",
      Outcome == "suic_idea" ~ "Suicide thoughts",
      TRUE ~ Outcome
    )
  ) |> 
  mutate(
     Est_CI = sprintf("%.2f (%.2f, %.2f)", PR, CI_l, CI_u)
  )

glm_results
## # A tibble: 144 × 10
##    Outcome Exposure Profession Adjustment   beta     SE    PR  CI_l  CI_u Est_CI
##    <chr>   <chr>    <chr>      <chr>       <dbl>  <dbl> <dbl> <dbl> <dbl> <chr> 
##  1 Depres… Colleag… Doctor     Crude      -0.458 0.0365 0.633 0.589 0.679 0.63 …
##  2 Depres… Colleag… Doctor     Partially… -0.416 0.0366 0.660 0.614 0.709 0.66 …
##  3 Depres… Colleag… Doctor     Fully adj… -0.419 0.0368 0.658 0.612 0.707 0.66 …
##  4 Depres… Colleag… Nurse      Crude      -0.544 0.0402 0.580 0.536 0.628 0.58 …
##  5 Depres… Colleag… Nurse      Partially… -0.519 0.0403 0.595 0.550 0.644 0.59 …
##  6 Depres… Colleag… Nurse      Fully adj… -0.519 0.0404 0.595 0.550 0.644 0.59 …
##  7 Depres… Support… Doctor     Crude      -0.539 0.0375 0.583 0.542 0.627 0.58 …
##  8 Depres… Support… Doctor     Partially… -0.483 0.0376 0.617 0.573 0.664 0.62 …
##  9 Depres… Support… Doctor     Fully adj… -0.481 0.0378 0.618 0.574 0.666 0.62 …
## 10 Depres… Support… Nurse      Crude      -0.701 0.0422 0.496 0.457 0.539 0.50 …
## # ℹ 134 more rows
saveRDS(glm_results, "out/dataframes/glm_results_df.rds")
writexl::write_xlsx(glm_results, "out/dataframes/glm_results_df.xlsx")
  

# Load data

glm_results <- readRDS("out/dataframes/glm_results_df.rds")

# Table of results
tbl_binary_glm <- make_stratified_table(
  glm_results,
  "**GLM Multilevel models**",
  "Prevalence Ratio (95% CI). All models include Region as a second-order covariate."
)

tbl_binary_glm
GLM Multilevel models
Doctor
Nurse
Crude1 Partially adjusted2 Fully adjusted3 Crude1 Partially adjusted2 Fully adjusted3
Depression
Bullying 2.22 (2.07, 2.39) 2.02 (1.88, 2.17) 2.02 (1.88, 2.18) 2.65 (2.44, 2.87) 2.49 (2.29, 2.70) 2.49 (2.30, 2.71)
Sexual Harassment 1.78 (1.61, 1.96) 1.48 (1.34, 1.64) 1.49 (1.34, 1.65) 2.38 (2.13, 2.66) 2.07 (1.85, 2.32) 2.08 (1.86, 2.33)
Violent threats 1.99 (1.85, 2.15) 1.84 (1.70, 1.99) 1.85 (1.71, 2.00) 2.28 (2.08, 2.51) 2.11 (1.92, 2.32) 2.12 (1.93, 2.34)
Physical violence 1.68 (1.44, 1.97) 1.49 (1.27, 1.75) 1.49 (1.27, 1.76) 2.23 (1.93, 2.59) 2.02 (1.74, 2.35) 2.02 (1.74, 2.36)
Colleague support 0.63 (0.59, 0.68) 0.66 (0.61, 0.71) 0.66 (0.61, 0.71) 0.58 (0.54, 0.63) 0.59 (0.55, 0.64) 0.59 (0.55, 0.64)
Support from superiors 0.58 (0.54, 0.63) 0.62 (0.57, 0.66) 0.62 (0.57, 0.67) 0.50 (0.46, 0.54) 0.52 (0.48, 0.56) 0.52 (0.48, 0.56)
Meaning in work 0.48 (0.43, 0.52) 0.50 (0.46, 0.55) 0.50 (0.46, 0.55) 0.42 (0.38, 0.46) 0.43 (0.39, 0.48) 0.44 (0.40, 0.48)
Purpose in work 0.45 (0.41, 0.50) 0.48 (0.43, 0.53) 0.48 (0.44, 0.53) 0.46 (0.41, 0.51) 0.48 (0.43, 0.54) 0.49 (0.44, 0.55)
Anxiety
Bullying 2.33 (2.14, 2.53) 2.09 (1.92, 2.28) 2.10 (1.92, 2.29) 2.77 (2.52, 3.04) 2.65 (2.41, 2.92) 2.66 (2.42, 2.93)
Sexual Harassment 1.97 (1.75, 2.20) 1.61 (1.43, 1.81) 1.62 (1.44, 1.82) 2.53 (2.23, 2.87) 2.26 (1.99, 2.58) 2.28 (2.00, 2.60)
Violent threats 2.06 (1.89, 2.26) 1.92 (1.75, 2.10) 1.93 (1.76, 2.12) 2.35 (2.10, 2.62) 2.25 (2.01, 2.52) 2.27 (2.03, 2.54)
Physical violence 1.96 (1.64, 2.33) 1.74 (1.45, 2.08) 1.79 (1.49, 2.15) 2.24 (1.89, 2.67) 2.11 (1.77, 2.52) 2.14 (1.80, 2.56)
Colleague support 0.62 (0.57, 0.68) 0.65 (0.60, 0.71) 0.65 (0.60, 0.71) 0.57 (0.52, 0.63) 0.58 (0.53, 0.63) 0.57 (0.52, 0.63)
Support from superiors 0.56 (0.52, 0.61) 0.60 (0.55, 0.65) 0.60 (0.54, 0.65) 0.50 (0.45, 0.55) 0.51 (0.47, 0.57) 0.51 (0.47, 0.57)
Meaning in work 0.47 (0.43, 0.53) 0.49 (0.44, 0.55) 0.50 (0.45, 0.55) 0.46 (0.41, 0.51) 0.47 (0.42, 0.52) 0.47 (0.42, 0.53)
Purpose in work 0.44 (0.39, 0.49) 0.46 (0.41, 0.52) 0.47 (0.41, 0.53) 0.49 (0.43, 0.55) 0.50 (0.44, 0.57) 0.51 (0.45, 0.58)
Suicide thoughts
Bullying 2.49 (2.21, 2.81) 2.22 (1.96, 2.51) 2.22 (1.96, 2.51) 3.39 (2.97, 3.86) 3.13 (2.74, 3.58) 3.11 (2.73, 3.56)
Sexual Harassment 2.61 (2.25, 3.02) 2.14 (1.84, 2.49) 2.13 (1.83, 2.48) 3.32 (2.82, 3.91) 2.81 (2.37, 3.32) 2.78 (2.35, 3.30)
Violent threats 2.49 (2.20, 2.82) 2.18 (1.92, 2.47) 2.18 (1.92, 2.48) 2.88 (2.49, 3.33) 2.59 (2.23, 3.01) 2.56 (2.20, 2.99)
Physical violence 2.85 (2.31, 3.52) 2.34 (1.89, 2.90) 2.37 (1.90, 2.95) 3.12 (2.52, 3.85) 2.69 (2.17, 3.34) 2.68 (2.16, 3.34)
Colleague support 0.60 (0.53, 0.68) 0.64 (0.56, 0.72) 0.64 (0.57, 0.72) 0.51 (0.45, 0.59) 0.52 (0.46, 0.60) 0.52 (0.46, 0.60)
Support from superiors 0.56 (0.50, 0.63) 0.61 (0.54, 0.69) 0.61 (0.54, 0.69) 0.53 (0.46, 0.61) 0.56 (0.49, 0.64) 0.55 (0.48, 0.63)
Meaning in work 0.40 (0.35, 0.47) 0.43 (0.37, 0.50) 0.44 (0.38, 0.51) 0.44 (0.38, 0.52) 0.47 (0.40, 0.55) 0.47 (0.40, 0.55)
Purpose in work 0.35 (0.30, 0.41) 0.38 (0.33, 0.45) 0.39 (0.33, 0.46) 0.41 (0.35, 0.49) 0.44 (0.37, 0.52) 0.44 (0.37, 0.52)
Prevalence Ratio (95% CI). All models include Region as a second-order covariate.
1 Region as second-order covariate only.
2 Adjusted by Gender, Age group and Proximity to combat areas and occupied territories .
3 Partially adjusted models plus specific covariates: Bullying and sexual harassment adjusted by Healthcare setting, Post-graduate training and Length of service. Violent threats and physical violence adjusted by Healthcare setting. Support from colleagues or superiors adjusted by Healthcare setting and Length of service. Finding meaning or purpose in job adjusted by Healthcare setting, Relationship status, Having children, and Length of service.
gtsave(tbl_binary_glm, "out/tables/glm_res_tbl.docx")


ls() |> 
  str_subset("^glm_") |> 
  rm(list = _)

rm(glm_se_ratios, make_stratified_table, run_crude_glm, run_glm_adj)

GLM Dose-Response models

analysis_plan_dose <- tribble(
  ~Exposure,     ~Covar_Key,
  "work_21", "peer",
  "work_22", "peer",
  "work_31", "viol",
  "work_32", "viol",
  "work_30", "har_bul",
  "work_33", "har_bul",
  "wb_wami_1", "meanpur",
  "wb_wami_2", "meanpur",
)

outcomes_map_dose <- tribble(
  ~Outcome,    ~Family,
  "phq_sc",    "gaussian",
  "gad_sc",    "gaussian",
  "mh_phq_9",  "gaussian",
)


# Define exposure-outcome combinations
tasks_dose <- expand_grid(
  out_row = outcomes_map_dose,
  exp_row = analysis_plan_dose,
) |> 
  tidyr::unpack(cols = c(out_row, exp_row))


dose_all <- pmap_dfr(list(
  tasks_dose$Outcome,
  tasks_dose$Family,
  tasks_dose$Exposure,
  tasks_dose$Covar_Key
  ), function(outcome, family, exposure, cov_key) {
  
  message(paste("Processing:", outcome, "&", exposure))

  
  res_adj <- run_glm_dose_emm(
    data = ds_ua,
    outcome_var = outcome,
    exposure_var = exposure,
    confounder_list = covariate_map[[cov_key]],
    model_label = "Fully adjusted"
  ) 
  
  print(res_adj)
})
## Processing: phq_sc & work_21
## Loading saved bundle: dose_dep_cols_fully_adjusted.rds
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 19420' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 19420)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 19420' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 19420)' or larger];
## but be warned that this may result in large computation time and memory use.
##   Outcome Exposure               Level  estimate conf.low conf.high
## 1  phq_sc  work_21 Never / Hardly ever 10.363076 9.847523 10.878629
## 2  phq_sc  work_21              Seldom  9.513735 9.097535  9.929935
## 3  phq_sc  work_21           Sometimes  7.946966 7.578833  8.315099
## 4  phq_sc  work_21               Often  7.246105 6.881685  7.610524
## 5  phq_sc  work_21              Always  5.526441 5.158099  5.894784
##            Model N_Analysis
## 1 Fully adjusted      19420
## 2 Fully adjusted      19420
## 3 Fully adjusted      19420
## 4 Fully adjusted      19420
## 5 Fully adjusted      19420
## Processing: phq_sc & work_22
## Loading saved bundle: dose_dep_sup_fully_adjusted.rds
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 19414' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 19414)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 19414' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 19414)' or larger];
## but be warned that this may result in large computation time and memory use.
##   Outcome Exposure               Level  estimate conf.low conf.high
## 1  phq_sc  work_22 Never / Hardly ever 10.388833 9.983641 10.794025
## 2  phq_sc  work_22              Seldom  9.170733 8.776369  9.565097
## 3  phq_sc  work_22           Sometimes  7.813671 7.450037  8.177305
## 4  phq_sc  work_22               Often  7.044911 6.680163  7.409660
## 5  phq_sc  work_22              Always  5.526779 5.168358  5.885201
##            Model N_Analysis
## 1 Fully adjusted      19414
## 2 Fully adjusted      19414
## 3 Fully adjusted      19414
## 4 Fully adjusted      19414
## 5 Fully adjusted      19414
## Processing: phq_sc & work_31
## Loading saved bundle: dose_dep_threats_fully_adjusted.rds
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 19462' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 19462)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 19462' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 19462)' or larger];
## but be warned that this may result in large computation time and memory use.
##   Outcome Exposure            Level  estimate  conf.low conf.high
## 1  phq_sc  work_31               No  6.493881  6.216748  6.771014
## 2  phq_sc  work_31 Yes, a few times  9.986213  9.648258 10.324168
## 3  phq_sc  work_31     Yes, monthly 11.865272 11.082108 12.648436
## 4  phq_sc  work_31      Yes, weekly 12.318530 11.433075 13.203986
## 5  phq_sc  work_31       Yes, daily 12.721124 11.766747 13.675501
##            Model N_Analysis
## 1 Fully adjusted      19462
## 2 Fully adjusted      19462
## 3 Fully adjusted      19462
## 4 Fully adjusted      19462
## 5 Fully adjusted      19462
## Processing: phq_sc & work_32
## Loading saved bundle: dose_dep_viol_fully_adjusted.rds
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 19465' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 19465)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 19465' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 19465)' or larger];
## but be warned that this may result in large computation time and memory use.
##   Outcome Exposure            Level  estimate  conf.low conf.high
## 1  phq_sc  work_32               No  7.125265  6.827682  7.422848
## 2  phq_sc  work_32 Yes, a few times 10.796591 10.233444 11.359738
## 3  phq_sc  work_32     Yes, monthly 12.159947 10.326065 13.993829
## 4  phq_sc  work_32      Yes, weekly 10.732886  8.946850 12.518921
## 5  phq_sc  work_32       Yes, daily 11.374434 10.045445 12.703423
##            Model N_Analysis
## 1 Fully adjusted      19465
## 2 Fully adjusted      19465
## 3 Fully adjusted      19465
## 4 Fully adjusted      19465
## 5 Fully adjusted      19465
## Processing: phq_sc & work_30
## Loading saved bundle: dose_dep_har_fully_adjusted.rds
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 19421' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 19421)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 19421' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 19421)' or larger];
## but be warned that this may result in large computation time and memory use.
##   Outcome Exposure            Level  estimate  conf.low conf.high
## 1  phq_sc  work_30               No  6.947317  6.611941  7.282692
## 2  phq_sc  work_30 Yes, a few times 10.653725 10.200519 11.106931
## 3  phq_sc  work_30     Yes, monthly 10.997003  9.857730 12.136275
## 4  phq_sc  work_30      Yes, weekly 10.844679  9.763083 11.926274
## 5  phq_sc  work_30       Yes, daily 11.562423 10.500516 12.624331
##            Model N_Analysis
## 1 Fully adjusted      19421
## 2 Fully adjusted      19421
## 3 Fully adjusted      19421
## 4 Fully adjusted      19421
## 5 Fully adjusted      19421
## Processing: phq_sc & work_33
## Loading saved bundle: dose_dep_bul_fully_adjusted.rds
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 19427' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 19427)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 19427' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 19427)' or larger];
## but be warned that this may result in large computation time and memory use.
##   Outcome Exposure            Level  estimate  conf.low conf.high
## 1  phq_sc  work_33               No  6.234596  5.924246  6.544945
## 2  phq_sc  work_33 Yes, a few times  9.978713  9.629255 10.328170
## 3  phq_sc  work_33     Yes, monthly 12.167895 11.539342 12.796447
## 4  phq_sc  work_33      Yes, weekly 13.128526 12.478244 13.778808
## 5  phq_sc  work_33       Yes, daily 14.121960 13.395403 14.848518
##            Model N_Analysis
## 1 Fully adjusted      19427
## 2 Fully adjusted      19427
## 3 Fully adjusted      19427
## 4 Fully adjusted      19427
## 5 Fully adjusted      19427
## Processing: phq_sc & wb_wami_1
## Loading saved bundle: dose_dep_mean_fully_adjusted.rds
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 19072' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 19072)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 19072' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 19072)' or larger];
## but be warned that this may result in large computation time and memory use.
##   Outcome  Exposure                   Level  estimate  conf.low conf.high
## 1  phq_sc wb_wami_1       Absolutely untrue 10.628644 10.160661 11.096627
## 2  phq_sc wb_wami_1           Mostly untrue  9.912557  9.512552 10.312561
## 3  phq_sc wb_wami_1 Neither true nor untrue  9.145213  8.779508  9.510918
## 4  phq_sc wb_wami_1             Mostly true  7.107908  6.765879  7.449937
## 5  phq_sc wb_wami_1         Absolutely true  5.393218  5.045072  5.741364
##            Model N_Analysis
## 1 Fully adjusted      19072
## 2 Fully adjusted      19072
## 3 Fully adjusted      19072
## 4 Fully adjusted      19072
## 5 Fully adjusted      19072
## Processing: phq_sc & wb_wami_2
## Loading saved bundle: dose_dep_purp_fully_adjusted.rds
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 19067' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 19067)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 19067' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 19067)' or larger];
## but be warned that this may result in large computation time and memory use.
##   Outcome  Exposure                   Level  estimate  conf.low conf.high
## 1  phq_sc wb_wami_2       Absolutely untrue 12.381539 11.805751 12.957328
## 2  phq_sc wb_wami_2           Mostly untrue 10.021557  9.587946 10.455168
## 3  phq_sc wb_wami_2 Neither true nor untrue  9.509440  9.128101  9.890778
## 4  phq_sc wb_wami_2             Mostly true  7.501071  7.163322  7.838821
## 5  phq_sc wb_wami_2         Absolutely true  6.022585  5.687151  6.358019
##            Model N_Analysis
## 1 Fully adjusted      19067
## 2 Fully adjusted      19067
## 3 Fully adjusted      19067
## 4 Fully adjusted      19067
## 5 Fully adjusted      19067
## Processing: gad_sc & work_21
## Loading saved bundle: dose_anx_cols_fully_adjusted.rds
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 19327' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 19327)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 19327' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 19327)' or larger];
## but be warned that this may result in large computation time and memory use.
##   Outcome Exposure               Level estimate conf.low conf.high
## 1  gad_sc  work_21 Never / Hardly ever 8.091918 7.636567  8.547269
## 2  gad_sc  work_21              Seldom 7.496980 7.132635  7.861326
## 3  gad_sc  work_21           Sometimes 6.219781 5.900879  6.538683
## 4  gad_sc  work_21               Often 5.785153 5.469945  6.100361
## 5  gad_sc  work_21              Always 4.479655 4.160506  4.798804
##            Model N_Analysis
## 1 Fully adjusted      19327
## 2 Fully adjusted      19327
## 3 Fully adjusted      19327
## 4 Fully adjusted      19327
## 5 Fully adjusted      19327
## Processing: gad_sc & work_22
## Loading saved bundle: dose_anx_sup_fully_adjusted.rds
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 19319' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 19319)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 19319' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 19319)' or larger];
## but be warned that this may result in large computation time and memory use.
##   Outcome Exposure               Level estimate conf.low conf.high
## 1  gad_sc  work_22 Never / Hardly ever 8.132103 7.777041  8.487165
## 2  gad_sc  work_22              Seldom 7.237756 6.892799  7.582712
## 3  gad_sc  work_22           Sometimes 6.148538 5.832717  6.464359
## 4  gad_sc  work_22               Often 5.587018 5.270220  5.903815
## 5  gad_sc  work_22              Always 4.497388 4.186502  4.808274
##            Model N_Analysis
## 1 Fully adjusted      19319
## 2 Fully adjusted      19319
## 3 Fully adjusted      19319
## 4 Fully adjusted      19319
## 5 Fully adjusted      19319
## Processing: gad_sc & work_31
## Loading saved bundle: dose_anx_threats_fully_adjusted.rds
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 19367' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 19367)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 19367' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 19367)' or larger];
## but be warned that this may result in large computation time and memory use.
##   Outcome Exposure            Level  estimate conf.low conf.high          Model
## 1  gad_sc  work_31               No  5.248825 5.010636  5.487014 Fully adjusted
## 2  gad_sc  work_31 Yes, a few times  8.020915 7.725539  8.316291 Fully adjusted
## 3  gad_sc  work_31     Yes, monthly  9.525161 8.822561 10.227761 Fully adjusted
## 4  gad_sc  work_31      Yes, weekly  9.638510 8.838575 10.438445 Fully adjusted
## 5  gad_sc  work_31       Yes, daily 10.152591 9.291730 11.013451 Fully adjusted
##   N_Analysis
## 1      19367
## 2      19367
## 3      19367
## 4      19367
## 5      19367
## Processing: gad_sc & work_32
## Loading saved bundle: dose_anx_viol_fully_adjusted.rds
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 19366' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 19366)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 19366' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 19366)' or larger];
## but be warned that this may result in large computation time and memory use.
##   Outcome Exposure            Level estimate conf.low conf.high          Model
## 1  gad_sc  work_32               No 5.748004 5.493590  6.002418 Fully adjusted
## 2  gad_sc  work_32 Yes, a few times 8.625767 8.126863  9.124670 Fully adjusted
## 3  gad_sc  work_32     Yes, monthly 9.852536 8.185995 11.519078 Fully adjusted
## 4  gad_sc  work_32      Yes, weekly 8.593344 6.992030 10.194657 Fully adjusted
## 5  gad_sc  work_32       Yes, daily 9.065210 7.874921 10.255498 Fully adjusted
##   N_Analysis
## 1      19366
## 2      19366
## 3      19366
## 4      19366
## 5      19366
## Processing: gad_sc & work_30
## Loading saved bundle: dose_anx_har_fully_adjusted.rds
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 19325' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 19325)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 19325' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 19325)' or larger];
## but be warned that this may result in large computation time and memory use.
##   Outcome Exposure            Level estimate conf.low conf.high          Model
## 1  gad_sc  work_30               No 5.522418 5.231924  5.812911 Fully adjusted
## 2  gad_sc  work_30 Yes, a few times 8.468788 8.069171  8.868404 Fully adjusted
## 3  gad_sc  work_30     Yes, monthly 8.675785 7.658583  9.692988 Fully adjusted
## 4  gad_sc  work_30      Yes, weekly 8.396146 7.422224  9.370068 Fully adjusted
## 5  gad_sc  work_30       Yes, daily 8.868974 7.913200  9.824749 Fully adjusted
##   N_Analysis
## 1      19325
## 2      19325
## 3      19325
## 4      19325
## 5      19325
## Processing: gad_sc & work_33
## Loading saved bundle: dose_anx_bul_fully_adjusted.rds
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 19332' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 19332)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 19332' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 19332)' or larger];
## but be warned that this may result in large computation time and memory use.
##   Outcome Exposure            Level  estimate  conf.low conf.high
## 1  gad_sc  work_33               No  4.936351  4.665899  5.206802
## 2  gad_sc  work_33 Yes, a few times  7.919563  7.612349  8.226778
## 3  gad_sc  work_33     Yes, monthly  9.895488  9.330097 10.460879
## 4  gad_sc  work_33      Yes, weekly 10.360943  9.773168 10.948717
## 5  gad_sc  work_33       Yes, daily 11.385672 10.732312 12.039032
##            Model N_Analysis
## 1 Fully adjusted      19332
## 2 Fully adjusted      19332
## 3 Fully adjusted      19332
## 4 Fully adjusted      19332
## 5 Fully adjusted      19332
## Processing: gad_sc & wb_wami_1
## Loading saved bundle: dose_anx_mean_fully_adjusted.rds
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 19068' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 19068)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 19068' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 19068)' or larger];
## but be warned that this may result in large computation time and memory use.
##   Outcome  Exposure                   Level estimate conf.low conf.high
## 1  gad_sc wb_wami_1       Absolutely untrue 8.024623 7.606465  8.442782
## 2  gad_sc wb_wami_1           Mostly untrue 7.648236 7.293441  8.003032
## 3  gad_sc wb_wami_1 Neither true nor untrue 7.086709 6.764056  7.409363
## 4  gad_sc wb_wami_1             Mostly true 5.629727 5.329523  5.929931
## 5  gad_sc wb_wami_1         Absolutely true 4.415986 4.110003  4.721969
##            Model N_Analysis
## 1 Fully adjusted      19068
## 2 Fully adjusted      19068
## 3 Fully adjusted      19068
## 4 Fully adjusted      19068
## 5 Fully adjusted      19068
## Processing: gad_sc & wb_wami_2
## Loading saved bundle: dose_anx_purp_fully_adjusted.rds
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 19064' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 19064)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 19064' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 19064)' or larger];
## but be warned that this may result in large computation time and memory use.
##   Outcome  Exposure                   Level estimate conf.low conf.high
## 1  gad_sc wb_wami_2       Absolutely untrue 9.244481 8.726893  9.762068
## 2  gad_sc wb_wami_2           Mostly untrue 7.730779 7.343966  8.117593
## 3  gad_sc wb_wami_2 Neither true nor untrue 7.380740 7.042218  7.719262
## 4  gad_sc wb_wami_2             Mostly true 5.925516 5.627843  6.223190
## 5  gad_sc wb_wami_2         Absolutely true 4.815917 4.520348  5.111485
##            Model N_Analysis
## 1 Fully adjusted      19064
## 2 Fully adjusted      19064
## 3 Fully adjusted      19064
## 4 Fully adjusted      19064
## 5 Fully adjusted      19064
## Processing: mh_phq_9 & work_21
## Loading saved bundle: dose_suic_cols_fully_adjusted.rds
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 19508' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 19508)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 19508' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 19508)' or larger];
## but be warned that this may result in large computation time and memory use.
##    Outcome Exposure               Level  estimate  conf.low conf.high
## 1 mh_phq_9  work_21 Never / Hardly ever 0.4261153 0.3875278 0.4647027
## 2 mh_phq_9  work_21              Seldom 0.2856393 0.2562579 0.3150207
## 3 mh_phq_9  work_21           Sometimes 0.2219403 0.1973807 0.2464999
## 4 mh_phq_9  work_21               Often 0.1911216 0.1669513 0.2152919
## 5 mh_phq_9  work_21              Always 0.1479667 0.1234016 0.1725319
##            Model N_Analysis
## 1 Fully adjusted      19508
## 2 Fully adjusted      19508
## 3 Fully adjusted      19508
## 4 Fully adjusted      19508
## 5 Fully adjusted      19508
## Processing: mh_phq_9 & work_22
## Loading saved bundle: dose_suic_sup_fully_adjusted.rds
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 19499' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 19499)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 19499' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 19499)' or larger];
## but be warned that this may result in large computation time and memory use.
##    Outcome Exposure               Level  estimate  conf.low conf.high
## 1 mh_phq_9  work_22 Never / Hardly ever 0.3335940 0.3048539 0.3623340
## 2 mh_phq_9  work_22              Seldom 0.2724634 0.2448177 0.3001092
## 3 mh_phq_9  work_22           Sometimes 0.2096436 0.1850993 0.2341879
## 4 mh_phq_9  work_22               Often 0.1841638 0.1595177 0.2088099
## 5 mh_phq_9  work_22              Always 0.1591480 0.1351875 0.1831086
##            Model N_Analysis
## 1 Fully adjusted      19499
## 2 Fully adjusted      19499
## 3 Fully adjusted      19499
## 4 Fully adjusted      19499
## 5 Fully adjusted      19499
## Processing: mh_phq_9 & work_31
## Loading saved bundle: dose_suic_threats_fully_adjusted.rds
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 19550' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 19550)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 19550' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 19550)' or larger];
## but be warned that this may result in large computation time and memory use.
##    Outcome Exposure            Level  estimate  conf.low conf.high
## 1 mh_phq_9  work_31               No 0.1326168 0.1154523 0.1497812
## 2 mh_phq_9  work_31 Yes, a few times 0.2801490 0.2567130 0.3035850
## 3 mh_phq_9  work_31     Yes, monthly 0.3935564 0.3307887 0.4563241
## 4 mh_phq_9  work_31      Yes, weekly 0.6008730 0.5293428 0.6724031
## 5 mh_phq_9  work_31       Yes, daily 0.6616636 0.5849075 0.7384196
##            Model N_Analysis
## 1 Fully adjusted      19550
## 2 Fully adjusted      19550
## 3 Fully adjusted      19550
## 4 Fully adjusted      19550
## 5 Fully adjusted      19550
## Processing: mh_phq_9 & work_32
## Loading saved bundle: dose_suic_viol_fully_adjusted.rds
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 19553' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 19553)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 19553' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 19553)' or larger];
## but be warned that this may result in large computation time and memory use.
##    Outcome Exposure            Level  estimate  conf.low conf.high
## 1 mh_phq_9  work_32               No 0.1594294 0.1417022 0.1771567
## 2 mh_phq_9  work_32 Yes, a few times 0.3630296 0.3204588 0.4056003
## 3 mh_phq_9  work_32     Yes, monthly 0.5540771 0.4059895 0.7021647
## 4 mh_phq_9  work_32      Yes, weekly 0.7255865 0.5832126 0.8679604
## 5 mh_phq_9  work_32       Yes, daily 0.9496561 0.8436514 1.0556608
##            Model N_Analysis
## 1 Fully adjusted      19553
## 2 Fully adjusted      19553
## 3 Fully adjusted      19553
## 4 Fully adjusted      19553
## 5 Fully adjusted      19553
## Processing: mh_phq_9 & work_30
## Loading saved bundle: dose_suic_har_fully_adjusted.rds
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 19508' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 19508)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 19508' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 19508)' or larger];
## but be warned that this may result in large computation time and memory use.
##    Outcome Exposure            Level  estimate  conf.low conf.high
## 1 mh_phq_9  work_30               No 0.1777764 0.1559215 0.1996314
## 2 mh_phq_9  work_30 Yes, a few times 0.3814765 0.3483884 0.4145646
## 3 mh_phq_9  work_30     Yes, monthly 0.4472742 0.3560333 0.5385150
## 4 mh_phq_9  work_30      Yes, weekly 0.4919372 0.4054388 0.5784356
## 5 mh_phq_9  work_30       Yes, daily 0.7711869 0.6862830 0.8560908
##            Model N_Analysis
## 1 Fully adjusted      19508
## 2 Fully adjusted      19508
## 3 Fully adjusted      19508
## 4 Fully adjusted      19508
## 5 Fully adjusted      19508
## Processing: mh_phq_9 & work_33
## Loading saved bundle: dose_suic_bul_fully_adjusted.rds
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 19512' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 19512)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 19512' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 19512)' or larger];
## but be warned that this may result in large computation time and memory use.
##    Outcome Exposure            Level  estimate  conf.low conf.high
## 1 mh_phq_9  work_33               No 0.1574605 0.1364212 0.1784998
## 2 mh_phq_9  work_33 Yes, a few times 0.2864191 0.2613921 0.3114460
## 3 mh_phq_9  work_33     Yes, monthly 0.4757194 0.4248866 0.5265521
## 4 mh_phq_9  work_33      Yes, weekly 0.4917597 0.4390195 0.5445000
## 5 mh_phq_9  work_33       Yes, daily 0.6779867 0.6187704 0.7372029
##            Model N_Analysis
## 1 Fully adjusted      19512
## 2 Fully adjusted      19512
## 3 Fully adjusted      19512
## 4 Fully adjusted      19512
## 5 Fully adjusted      19512
## Processing: mh_phq_9 & wb_wami_1
## Loading saved bundle: dose_suic_mean_fully_adjusted.rds
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 19145' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 19145)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 19145' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 19145)' or larger];
## but be warned that this may result in large computation time and memory use.
##    Outcome  Exposure                   Level  estimate  conf.low conf.high
## 1 mh_phq_9 wb_wami_1       Absolutely untrue 0.3921259 0.3568040 0.4274478
## 2 mh_phq_9 wb_wami_1           Mostly untrue 0.2893525 0.2604499 0.3182551
## 3 mh_phq_9 wb_wami_1 Neither true nor untrue 0.2608666 0.2353646 0.2863687
## 4 mh_phq_9 wb_wami_1             Mostly true 0.1876282 0.1645425 0.2107139
## 5 mh_phq_9 wb_wami_1         Absolutely true 0.1544227 0.1306970 0.1781483
##            Model N_Analysis
## 1 Fully adjusted      19145
## 2 Fully adjusted      19145
## 3 Fully adjusted      19145
## 4 Fully adjusted      19145
## 5 Fully adjusted      19145
## Processing: mh_phq_9 & wb_wami_2
## Loading saved bundle: dose_suic_purp_fully_adjusted.rds
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 19140' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 19140)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 19140' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 19140)' or larger];
## but be warned that this may result in large computation time and memory use.
##    Outcome  Exposure                   Level  estimate  conf.low conf.high
## 1 mh_phq_9 wb_wami_2       Absolutely untrue 0.5157833 0.4708218 0.5607447
## 2 mh_phq_9 wb_wami_2           Mostly untrue 0.3230118 0.2908764 0.3551472
## 3 mh_phq_9 wb_wami_2 Neither true nor untrue 0.2897936 0.2625895 0.3169977
## 4 mh_phq_9 wb_wami_2             Mostly true 0.2026302 0.1797418 0.2255185
## 5 mh_phq_9 wb_wami_2         Absolutely true 0.1592481 0.1365766 0.1819195
##            Model N_Analysis
## 1 Fully adjusted      19140
## 2 Fully adjusted      19140
## 3 Fully adjusted      19140
## 4 Fully adjusted      19140
## 5 Fully adjusted      19140
dose_all <- 
  dose_all |> 
  mutate(
    Est_CI = sprintf("%.2f (%.2f, %.2f)", estimate, conf.low, conf.high),
    Exposure = case_when(
      Exposure == "work_21" ~ "Colleague support",
      Exposure == "work_22" ~ "Support from superiors",
      Exposure == "work_31" ~ "Violent threats",
      Exposure == "work_32" ~ "Physical violence",
      Exposure == "work_30" ~ "Sexual Harassment",
      Exposure == "work_33" ~ "Bullying",
      Exposure == "wb_wami_1" ~ "Meaning in work",
      Exposure == "wb_wami_2" ~ "Purpose in work",
      TRUE ~ Exposure),
    Outcome = case_when(
      Outcome == "phq_sc" ~ "PHQ-9 score",
      Outcome == "gad_sc" ~ "GAD-7 score",
      Outcome == "mh_phq_9" ~ "PHQ-9 suicide item score",
      TRUE ~ Outcome
    ),
    Category = if_else(
      Exposure %in% c("Violent threats", "Physical violence",
                      "Sexual Harassment", "Bullying"),
      "Risk factor",
      "Protective factor")
    )

dose_all
##                      Outcome               Exposure                   Level
## 1                PHQ-9 score      Colleague support     Never / Hardly ever
## 2                PHQ-9 score      Colleague support                  Seldom
## 3                PHQ-9 score      Colleague support               Sometimes
## 4                PHQ-9 score      Colleague support                   Often
## 5                PHQ-9 score      Colleague support                  Always
## 6                PHQ-9 score Support from superiors     Never / Hardly ever
## 7                PHQ-9 score Support from superiors                  Seldom
## 8                PHQ-9 score Support from superiors               Sometimes
## 9                PHQ-9 score Support from superiors                   Often
## 10               PHQ-9 score Support from superiors                  Always
## 11               PHQ-9 score        Violent threats                      No
## 12               PHQ-9 score        Violent threats        Yes, a few times
## 13               PHQ-9 score        Violent threats            Yes, monthly
## 14               PHQ-9 score        Violent threats             Yes, weekly
## 15               PHQ-9 score        Violent threats              Yes, daily
## 16               PHQ-9 score      Physical violence                      No
## 17               PHQ-9 score      Physical violence        Yes, a few times
## 18               PHQ-9 score      Physical violence            Yes, monthly
## 19               PHQ-9 score      Physical violence             Yes, weekly
## 20               PHQ-9 score      Physical violence              Yes, daily
## 21               PHQ-9 score      Sexual Harassment                      No
## 22               PHQ-9 score      Sexual Harassment        Yes, a few times
## 23               PHQ-9 score      Sexual Harassment            Yes, monthly
## 24               PHQ-9 score      Sexual Harassment             Yes, weekly
## 25               PHQ-9 score      Sexual Harassment              Yes, daily
## 26               PHQ-9 score               Bullying                      No
## 27               PHQ-9 score               Bullying        Yes, a few times
## 28               PHQ-9 score               Bullying            Yes, monthly
## 29               PHQ-9 score               Bullying             Yes, weekly
## 30               PHQ-9 score               Bullying              Yes, daily
## 31               PHQ-9 score        Meaning in work       Absolutely untrue
## 32               PHQ-9 score        Meaning in work           Mostly untrue
## 33               PHQ-9 score        Meaning in work Neither true nor untrue
## 34               PHQ-9 score        Meaning in work             Mostly true
## 35               PHQ-9 score        Meaning in work         Absolutely true
## 36               PHQ-9 score        Purpose in work       Absolutely untrue
## 37               PHQ-9 score        Purpose in work           Mostly untrue
## 38               PHQ-9 score        Purpose in work Neither true nor untrue
## 39               PHQ-9 score        Purpose in work             Mostly true
## 40               PHQ-9 score        Purpose in work         Absolutely true
## 41               GAD-7 score      Colleague support     Never / Hardly ever
## 42               GAD-7 score      Colleague support                  Seldom
## 43               GAD-7 score      Colleague support               Sometimes
## 44               GAD-7 score      Colleague support                   Often
## 45               GAD-7 score      Colleague support                  Always
## 46               GAD-7 score Support from superiors     Never / Hardly ever
## 47               GAD-7 score Support from superiors                  Seldom
## 48               GAD-7 score Support from superiors               Sometimes
## 49               GAD-7 score Support from superiors                   Often
## 50               GAD-7 score Support from superiors                  Always
## 51               GAD-7 score        Violent threats                      No
## 52               GAD-7 score        Violent threats        Yes, a few times
## 53               GAD-7 score        Violent threats            Yes, monthly
## 54               GAD-7 score        Violent threats             Yes, weekly
## 55               GAD-7 score        Violent threats              Yes, daily
## 56               GAD-7 score      Physical violence                      No
## 57               GAD-7 score      Physical violence        Yes, a few times
## 58               GAD-7 score      Physical violence            Yes, monthly
## 59               GAD-7 score      Physical violence             Yes, weekly
## 60               GAD-7 score      Physical violence              Yes, daily
## 61               GAD-7 score      Sexual Harassment                      No
## 62               GAD-7 score      Sexual Harassment        Yes, a few times
## 63               GAD-7 score      Sexual Harassment            Yes, monthly
## 64               GAD-7 score      Sexual Harassment             Yes, weekly
## 65               GAD-7 score      Sexual Harassment              Yes, daily
## 66               GAD-7 score               Bullying                      No
## 67               GAD-7 score               Bullying        Yes, a few times
## 68               GAD-7 score               Bullying            Yes, monthly
## 69               GAD-7 score               Bullying             Yes, weekly
## 70               GAD-7 score               Bullying              Yes, daily
## 71               GAD-7 score        Meaning in work       Absolutely untrue
## 72               GAD-7 score        Meaning in work           Mostly untrue
## 73               GAD-7 score        Meaning in work Neither true nor untrue
## 74               GAD-7 score        Meaning in work             Mostly true
## 75               GAD-7 score        Meaning in work         Absolutely true
## 76               GAD-7 score        Purpose in work       Absolutely untrue
## 77               GAD-7 score        Purpose in work           Mostly untrue
## 78               GAD-7 score        Purpose in work Neither true nor untrue
## 79               GAD-7 score        Purpose in work             Mostly true
## 80               GAD-7 score        Purpose in work         Absolutely true
## 81  PHQ-9 suicide item score      Colleague support     Never / Hardly ever
## 82  PHQ-9 suicide item score      Colleague support                  Seldom
## 83  PHQ-9 suicide item score      Colleague support               Sometimes
## 84  PHQ-9 suicide item score      Colleague support                   Often
## 85  PHQ-9 suicide item score      Colleague support                  Always
## 86  PHQ-9 suicide item score Support from superiors     Never / Hardly ever
## 87  PHQ-9 suicide item score Support from superiors                  Seldom
## 88  PHQ-9 suicide item score Support from superiors               Sometimes
## 89  PHQ-9 suicide item score Support from superiors                   Often
## 90  PHQ-9 suicide item score Support from superiors                  Always
## 91  PHQ-9 suicide item score        Violent threats                      No
## 92  PHQ-9 suicide item score        Violent threats        Yes, a few times
## 93  PHQ-9 suicide item score        Violent threats            Yes, monthly
## 94  PHQ-9 suicide item score        Violent threats             Yes, weekly
## 95  PHQ-9 suicide item score        Violent threats              Yes, daily
## 96  PHQ-9 suicide item score      Physical violence                      No
## 97  PHQ-9 suicide item score      Physical violence        Yes, a few times
## 98  PHQ-9 suicide item score      Physical violence            Yes, monthly
## 99  PHQ-9 suicide item score      Physical violence             Yes, weekly
## 100 PHQ-9 suicide item score      Physical violence              Yes, daily
## 101 PHQ-9 suicide item score      Sexual Harassment                      No
## 102 PHQ-9 suicide item score      Sexual Harassment        Yes, a few times
## 103 PHQ-9 suicide item score      Sexual Harassment            Yes, monthly
## 104 PHQ-9 suicide item score      Sexual Harassment             Yes, weekly
## 105 PHQ-9 suicide item score      Sexual Harassment              Yes, daily
## 106 PHQ-9 suicide item score               Bullying                      No
## 107 PHQ-9 suicide item score               Bullying        Yes, a few times
## 108 PHQ-9 suicide item score               Bullying            Yes, monthly
## 109 PHQ-9 suicide item score               Bullying             Yes, weekly
## 110 PHQ-9 suicide item score               Bullying              Yes, daily
## 111 PHQ-9 suicide item score        Meaning in work       Absolutely untrue
## 112 PHQ-9 suicide item score        Meaning in work           Mostly untrue
## 113 PHQ-9 suicide item score        Meaning in work Neither true nor untrue
## 114 PHQ-9 suicide item score        Meaning in work             Mostly true
## 115 PHQ-9 suicide item score        Meaning in work         Absolutely true
## 116 PHQ-9 suicide item score        Purpose in work       Absolutely untrue
## 117 PHQ-9 suicide item score        Purpose in work           Mostly untrue
## 118 PHQ-9 suicide item score        Purpose in work Neither true nor untrue
## 119 PHQ-9 suicide item score        Purpose in work             Mostly true
## 120 PHQ-9 suicide item score        Purpose in work         Absolutely true
##       estimate   conf.low  conf.high          Model N_Analysis
## 1   10.3630761  9.8475228 10.8786295 Fully adjusted      19420
## 2    9.5137350  9.0975349  9.9299352 Fully adjusted      19420
## 3    7.9469661  7.5788334  8.3150987 Fully adjusted      19420
## 4    7.2461047  6.8816852  7.6105242 Fully adjusted      19420
## 5    5.5264413  5.1580987  5.8947839 Fully adjusted      19420
## 6   10.3888333  9.9836414 10.7940251 Fully adjusted      19414
## 7    9.1707329  8.7763692  9.5650966 Fully adjusted      19414
## 8    7.8136708  7.4500366  8.1773050 Fully adjusted      19414
## 9    7.0449115  6.6801633  7.4096596 Fully adjusted      19414
## 10   5.5267791  5.1683576  5.8852006 Fully adjusted      19414
## 11   6.4938806  6.2167477  6.7710135 Fully adjusted      19462
## 12   9.9862128  9.6482579 10.3241677 Fully adjusted      19462
## 13  11.8652719 11.0821075 12.6484363 Fully adjusted      19462
## 14  12.3185301 11.4330746 13.2039857 Fully adjusted      19462
## 15  12.7211240 11.7667466 13.6755015 Fully adjusted      19462
## 16   7.1252651  6.8276817  7.4228484 Fully adjusted      19465
## 17  10.7965910 10.2334437 11.3597384 Fully adjusted      19465
## 18  12.1599468 10.3260649 13.9938287 Fully adjusted      19465
## 19  10.7328857  8.9468503 12.5189210 Fully adjusted      19465
## 20  11.3744341 10.0454454 12.7034229 Fully adjusted      19465
## 21   6.9473170  6.6119415  7.2826924 Fully adjusted      19421
## 22  10.6537254 10.2005193 11.1069315 Fully adjusted      19421
## 23  10.9970029  9.8577304 12.1362754 Fully adjusted      19421
## 24  10.8446788  9.7630830 11.9262745 Fully adjusted      19421
## 25  11.5624233 10.5005158 12.6243309 Fully adjusted      19421
## 26   6.2345956  5.9242462  6.5449449 Fully adjusted      19427
## 27   9.9787128  9.6292551 10.3281705 Fully adjusted      19427
## 28  12.1678946 11.5393422 12.7964469 Fully adjusted      19427
## 29  13.1285263 12.4782444 13.7788082 Fully adjusted      19427
## 30  14.1219605 13.3954029 14.8485181 Fully adjusted      19427
## 31  10.6286439 10.1606612 11.0966266 Fully adjusted      19072
## 32   9.9125568  9.5125522 10.3125614 Fully adjusted      19072
## 33   9.1452130  8.7795083  9.5109178 Fully adjusted      19072
## 34   7.1079080  6.7658790  7.4499371 Fully adjusted      19072
## 35   5.3932181  5.0450719  5.7413643 Fully adjusted      19072
## 36  12.3815394 11.8057507 12.9573281 Fully adjusted      19067
## 37  10.0215567  9.5879456 10.4551678 Fully adjusted      19067
## 38   9.5094395  9.1281012  9.8907779 Fully adjusted      19067
## 39   7.5010715  7.1633222  7.8388207 Fully adjusted      19067
## 40   6.0225853  5.6871514  6.3580193 Fully adjusted      19067
## 41   8.0919178  7.6365671  8.5472685 Fully adjusted      19327
## 42   7.4969805  7.1326346  7.8613263 Fully adjusted      19327
## 43   6.2197806  5.9008787  6.5386825 Fully adjusted      19327
## 44   5.7851532  5.4699449  6.1003615 Fully adjusted      19327
## 45   4.4796553  4.1605064  4.7988042 Fully adjusted      19327
## 46   8.1321034  7.7770413  8.4871655 Fully adjusted      19319
## 47   7.2377555  6.8927994  7.5827117 Fully adjusted      19319
## 48   6.1485376  5.8327167  6.4643585 Fully adjusted      19319
## 49   5.5870179  5.2702203  5.9038155 Fully adjusted      19319
## 50   4.4973879  4.1865018  4.8082741 Fully adjusted      19319
## 51   5.2488248  5.0106357  5.4870138 Fully adjusted      19367
## 52   8.0209150  7.7255394  8.3162905 Fully adjusted      19367
## 53   9.5251608  8.8225605 10.2277610 Fully adjusted      19367
## 54   9.6385101  8.8385755 10.4384448 Fully adjusted      19367
## 55  10.1525908  9.2917303 11.0134513 Fully adjusted      19367
## 56   5.7480041  5.4935905  6.0024178 Fully adjusted      19366
## 57   8.6257665  8.1268634  9.1246696 Fully adjusted      19366
## 58   9.8525365  8.1859949 11.5190781 Fully adjusted      19366
## 59   8.5933435  6.9920303 10.1946567 Fully adjusted      19366
## 60   9.0652096  7.8749208 10.2554985 Fully adjusted      19366
## 61   5.5224179  5.2319244  5.8129113 Fully adjusted      19325
## 62   8.4687875  8.0691711  8.8684039 Fully adjusted      19325
## 63   8.6757854  7.6585827  9.6929881 Fully adjusted      19325
## 64   8.3961463  7.4222242  9.3700684 Fully adjusted      19325
## 65   8.8689745  7.9132004  9.8247485 Fully adjusted      19325
## 66   4.9363508  4.6658993  5.2068023 Fully adjusted      19332
## 67   7.9195634  7.6123489  8.2267778 Fully adjusted      19332
## 68   9.8954876  9.3300966 10.4608785 Fully adjusted      19332
## 69  10.3609425  9.7731682 10.9487168 Fully adjusted      19332
## 70  11.3856719 10.7323121 12.0390316 Fully adjusted      19332
## 71   8.0246232  7.6064649  8.4427816 Fully adjusted      19068
## 72   7.6482362  7.2934407  8.0030317 Fully adjusted      19068
## 73   7.0867094  6.7640557  7.4093631 Fully adjusted      19068
## 74   5.6297270  5.3295234  5.9299306 Fully adjusted      19068
## 75   4.4159862  4.1100034  4.7219689 Fully adjusted      19068
## 76   9.2444806  8.7268930  9.7620682 Fully adjusted      19064
## 77   7.7307795  7.3439659  8.1175931 Fully adjusted      19064
## 78   7.3807404  7.0422184  7.7192625 Fully adjusted      19064
## 79   5.9255163  5.6278428  6.2231897 Fully adjusted      19064
## 80   4.8159166  4.5203480  5.1114852 Fully adjusted      19064
## 81   0.4261153  0.3875278  0.4647027 Fully adjusted      19508
## 82   0.2856393  0.2562579  0.3150207 Fully adjusted      19508
## 83   0.2219403  0.1973807  0.2464999 Fully adjusted      19508
## 84   0.1911216  0.1669513  0.2152919 Fully adjusted      19508
## 85   0.1479667  0.1234016  0.1725319 Fully adjusted      19508
## 86   0.3335940  0.3048539  0.3623340 Fully adjusted      19499
## 87   0.2724634  0.2448177  0.3001092 Fully adjusted      19499
## 88   0.2096436  0.1850993  0.2341879 Fully adjusted      19499
## 89   0.1841638  0.1595177  0.2088099 Fully adjusted      19499
## 90   0.1591480  0.1351875  0.1831086 Fully adjusted      19499
## 91   0.1326168  0.1154523  0.1497812 Fully adjusted      19550
## 92   0.2801490  0.2567130  0.3035850 Fully adjusted      19550
## 93   0.3935564  0.3307887  0.4563241 Fully adjusted      19550
## 94   0.6008730  0.5293428  0.6724031 Fully adjusted      19550
## 95   0.6616636  0.5849075  0.7384196 Fully adjusted      19550
## 96   0.1594294  0.1417022  0.1771567 Fully adjusted      19553
## 97   0.3630296  0.3204588  0.4056003 Fully adjusted      19553
## 98   0.5540771  0.4059895  0.7021647 Fully adjusted      19553
## 99   0.7255865  0.5832126  0.8679604 Fully adjusted      19553
## 100  0.9496561  0.8436514  1.0556608 Fully adjusted      19553
## 101  0.1777764  0.1559215  0.1996314 Fully adjusted      19508
## 102  0.3814765  0.3483884  0.4145646 Fully adjusted      19508
## 103  0.4472742  0.3560333  0.5385150 Fully adjusted      19508
## 104  0.4919372  0.4054388  0.5784356 Fully adjusted      19508
## 105  0.7711869  0.6862830  0.8560908 Fully adjusted      19508
## 106  0.1574605  0.1364212  0.1784998 Fully adjusted      19512
## 107  0.2864191  0.2613921  0.3114460 Fully adjusted      19512
## 108  0.4757194  0.4248866  0.5265521 Fully adjusted      19512
## 109  0.4917597  0.4390195  0.5445000 Fully adjusted      19512
## 110  0.6779867  0.6187704  0.7372029 Fully adjusted      19512
## 111  0.3921259  0.3568040  0.4274478 Fully adjusted      19145
## 112  0.2893525  0.2604499  0.3182551 Fully adjusted      19145
## 113  0.2608666  0.2353646  0.2863687 Fully adjusted      19145
## 114  0.1876282  0.1645425  0.2107139 Fully adjusted      19145
## 115  0.1544227  0.1306970  0.1781483 Fully adjusted      19145
## 116  0.5157833  0.4708218  0.5607447 Fully adjusted      19140
## 117  0.3230118  0.2908764  0.3551472 Fully adjusted      19140
## 118  0.2897936  0.2625895  0.3169977 Fully adjusted      19140
## 119  0.2026302  0.1797418  0.2255185 Fully adjusted      19140
## 120  0.1592481  0.1365766  0.1819195 Fully adjusted      19140
##                   Est_CI          Category
## 1    10.36 (9.85, 10.88) Protective factor
## 2      9.51 (9.10, 9.93) Protective factor
## 3      7.95 (7.58, 8.32) Protective factor
## 4      7.25 (6.88, 7.61) Protective factor
## 5      5.53 (5.16, 5.89) Protective factor
## 6    10.39 (9.98, 10.79) Protective factor
## 7      9.17 (8.78, 9.57) Protective factor
## 8      7.81 (7.45, 8.18) Protective factor
## 9      7.04 (6.68, 7.41) Protective factor
## 10     5.53 (5.17, 5.89) Protective factor
## 11     6.49 (6.22, 6.77)       Risk factor
## 12    9.99 (9.65, 10.32)       Risk factor
## 13  11.87 (11.08, 12.65)       Risk factor
## 14  12.32 (11.43, 13.20)       Risk factor
## 15  12.72 (11.77, 13.68)       Risk factor
## 16     7.13 (6.83, 7.42)       Risk factor
## 17  10.80 (10.23, 11.36)       Risk factor
## 18  12.16 (10.33, 13.99)       Risk factor
## 19   10.73 (8.95, 12.52)       Risk factor
## 20  11.37 (10.05, 12.70)       Risk factor
## 21     6.95 (6.61, 7.28)       Risk factor
## 22  10.65 (10.20, 11.11)       Risk factor
## 23   11.00 (9.86, 12.14)       Risk factor
## 24   10.84 (9.76, 11.93)       Risk factor
## 25  11.56 (10.50, 12.62)       Risk factor
## 26     6.23 (5.92, 6.54)       Risk factor
## 27    9.98 (9.63, 10.33)       Risk factor
## 28  12.17 (11.54, 12.80)       Risk factor
## 29  13.13 (12.48, 13.78)       Risk factor
## 30  14.12 (13.40, 14.85)       Risk factor
## 31  10.63 (10.16, 11.10) Protective factor
## 32    9.91 (9.51, 10.31) Protective factor
## 33     9.15 (8.78, 9.51) Protective factor
## 34     7.11 (6.77, 7.45) Protective factor
## 35     5.39 (5.05, 5.74) Protective factor
## 36  12.38 (11.81, 12.96) Protective factor
## 37   10.02 (9.59, 10.46) Protective factor
## 38     9.51 (9.13, 9.89) Protective factor
## 39     7.50 (7.16, 7.84) Protective factor
## 40     6.02 (5.69, 6.36) Protective factor
## 41     8.09 (7.64, 8.55) Protective factor
## 42     7.50 (7.13, 7.86) Protective factor
## 43     6.22 (5.90, 6.54) Protective factor
## 44     5.79 (5.47, 6.10) Protective factor
## 45     4.48 (4.16, 4.80) Protective factor
## 46     8.13 (7.78, 8.49) Protective factor
## 47     7.24 (6.89, 7.58) Protective factor
## 48     6.15 (5.83, 6.46) Protective factor
## 49     5.59 (5.27, 5.90) Protective factor
## 50     4.50 (4.19, 4.81) Protective factor
## 51     5.25 (5.01, 5.49)       Risk factor
## 52     8.02 (7.73, 8.32)       Risk factor
## 53    9.53 (8.82, 10.23)       Risk factor
## 54    9.64 (8.84, 10.44)       Risk factor
## 55   10.15 (9.29, 11.01)       Risk factor
## 56     5.75 (5.49, 6.00)       Risk factor
## 57     8.63 (8.13, 9.12)       Risk factor
## 58    9.85 (8.19, 11.52)       Risk factor
## 59    8.59 (6.99, 10.19)       Risk factor
## 60    9.07 (7.87, 10.26)       Risk factor
## 61     5.52 (5.23, 5.81)       Risk factor
## 62     8.47 (8.07, 8.87)       Risk factor
## 63     8.68 (7.66, 9.69)       Risk factor
## 64     8.40 (7.42, 9.37)       Risk factor
## 65     8.87 (7.91, 9.82)       Risk factor
## 66     4.94 (4.67, 5.21)       Risk factor
## 67     7.92 (7.61, 8.23)       Risk factor
## 68    9.90 (9.33, 10.46)       Risk factor
## 69   10.36 (9.77, 10.95)       Risk factor
## 70  11.39 (10.73, 12.04)       Risk factor
## 71     8.02 (7.61, 8.44) Protective factor
## 72     7.65 (7.29, 8.00) Protective factor
## 73     7.09 (6.76, 7.41) Protective factor
## 74     5.63 (5.33, 5.93) Protective factor
## 75     4.42 (4.11, 4.72) Protective factor
## 76     9.24 (8.73, 9.76) Protective factor
## 77     7.73 (7.34, 8.12) Protective factor
## 78     7.38 (7.04, 7.72) Protective factor
## 79     5.93 (5.63, 6.22) Protective factor
## 80     4.82 (4.52, 5.11) Protective factor
## 81     0.43 (0.39, 0.46) Protective factor
## 82     0.29 (0.26, 0.32) Protective factor
## 83     0.22 (0.20, 0.25) Protective factor
## 84     0.19 (0.17, 0.22) Protective factor
## 85     0.15 (0.12, 0.17) Protective factor
## 86     0.33 (0.30, 0.36) Protective factor
## 87     0.27 (0.24, 0.30) Protective factor
## 88     0.21 (0.19, 0.23) Protective factor
## 89     0.18 (0.16, 0.21) Protective factor
## 90     0.16 (0.14, 0.18) Protective factor
## 91     0.13 (0.12, 0.15)       Risk factor
## 92     0.28 (0.26, 0.30)       Risk factor
## 93     0.39 (0.33, 0.46)       Risk factor
## 94     0.60 (0.53, 0.67)       Risk factor
## 95     0.66 (0.58, 0.74)       Risk factor
## 96     0.16 (0.14, 0.18)       Risk factor
## 97     0.36 (0.32, 0.41)       Risk factor
## 98     0.55 (0.41, 0.70)       Risk factor
## 99     0.73 (0.58, 0.87)       Risk factor
## 100    0.95 (0.84, 1.06)       Risk factor
## 101    0.18 (0.16, 0.20)       Risk factor
## 102    0.38 (0.35, 0.41)       Risk factor
## 103    0.45 (0.36, 0.54)       Risk factor
## 104    0.49 (0.41, 0.58)       Risk factor
## 105    0.77 (0.69, 0.86)       Risk factor
## 106    0.16 (0.14, 0.18)       Risk factor
## 107    0.29 (0.26, 0.31)       Risk factor
## 108    0.48 (0.42, 0.53)       Risk factor
## 109    0.49 (0.44, 0.54)       Risk factor
## 110    0.68 (0.62, 0.74)       Risk factor
## 111    0.39 (0.36, 0.43) Protective factor
## 112    0.29 (0.26, 0.32) Protective factor
## 113    0.26 (0.24, 0.29) Protective factor
## 114    0.19 (0.16, 0.21) Protective factor
## 115    0.15 (0.13, 0.18) Protective factor
## 116    0.52 (0.47, 0.56) Protective factor
## 117    0.32 (0.29, 0.36) Protective factor
## 118    0.29 (0.26, 0.32) Protective factor
## 119    0.20 (0.18, 0.23) Protective factor
## 120    0.16 (0.14, 0.18) Protective factor
saveRDS(dose_all, "out/dataframes/dose_all.rds")
writexl::write_xlsx(dose_all, "out/dataframes/dose_all.xlsx")
dose_resp_df <- 
  readRDS("out/dataframes/dose_all.rds") 

# Custom palette: Purple -> Teal -> Green -> Lime
viridis_lime_palette <- c(
  "#440154", # Dark Purple
  "lightblue", # Blue/Teal
  "#35B779", # Medium Green
  "#B4DE2C"  # Lime Green
)

# Assign these colors to labels
custom_colors <- c(
  # Risk Factors 
  "Bullying"                = viridis_lime_palette[1],
  "Sexual Harassment"       = viridis_lime_palette[2],
  "Violent threats"         = viridis_lime_palette[3],
  "Physical violence"       = viridis_lime_palette[4],
  
  # Protective Factors
  "Colleague support"       = viridis_lime_palette[1],
  "Support from superiors"  = viridis_lime_palette[2],
  "Meaning in work"         = viridis_lime_palette[3],
  "Purpose in work"         = viridis_lime_palette[4]
)


dose_plots <-
  
  dose_resp_df |> 
  group_by(Outcome, Exposure) |> 
  mutate(Level_Index = row_number()) |> 
  ungroup() |> 
  mutate(Outcome = factor(Outcome, 
                          levels = c("PHQ-9 score",
                                     "GAD-7 score",
                                     "PHQ-9 suicide item score")),
         Exposure = factor(Exposure, levels = exposure_order)) |> 
  arrange(Outcome) |> 
  ggplot(aes(x = Level_Index, 
             y = estimate, 
             group = Exposure,
             colour = Exposure)) +
  geom_line(linewidth = 0.5,
            position = position_dodge(width = 0.2)) + 
  geom_point(size = 2,
             position = position_dodge(width = 0.2)) + 
  facet_grid(rows = vars(Outcome),
             cols = vars(Category),
             scales = "free",
             switch = "y") + 
  scale_colour_manual(values = custom_colors) +
  scale_x_continuous(breaks = 1:5, minor_breaks = NULL) +
  labs(
    x = "Level of exposure",
    y = "Score change estimate",
    colour ="Exposure"
  ) + 
  facetted_pos_scales(
    y = list(
      Outcome == "PHQ-9 score" ~ scale_y_continuous(
        limits = c(0, 27),
        breaks = c(0, 5, 10, 15, 20, 25)),
      Outcome == "GAD-7 score" ~ scale_y_continuous(
        limits = c(0, 21),
        breaks = c(0, 5, 10, 15, 20)),
      Outcome == 
        "PHQ-9 suicide item score" ~ scale_y_continuous(
        limits = c(0, 4),
        breaks = c(0, 1, 2, 3, 4))
    )
  ) + 
  theme_minimal() +
  theme(
    strip.placement = "outside",  
    strip.text.y.left = element_text(angle = 90, face = "bold", size = 10), 
    strip.text.x = element_text(face = "bold", size = 10),
    axis.text.x = element_text(size = 10),
    axis.title.x = element_text(size = 10),
    axis.text.y = element_text(size = 10),
    panel.border = element_rect(color = "black", fill = NA),  
    axis.title.y = element_blank(), 
    legend.position = "right",
    legend.key.width = unit(1.5, "cm")
  )

dose_plots

ggsave(filename = "dose_resp_plots.pdf",
       plot = dose_plots,
       path = "out/plots/",
       width = 170,
       height = 170,
       units = "mm",
       dpi = 320,
       scale = 1.5
       )

ls() |> 
  str_subset("^glm_") |> 
  rm(list = _)

Survey approach

Define design

ds_ua <- 
  ds_ua |> 
  filter(!is.na(scdm_2_rec))

# As we do not know the absolute numbers but only distributions, we use
# raking for adjusting our sample to the population
# First, define population totals (marginal targets)
pop_profession <- 
  data.frame(
    work_2 = c("Doctor", "Nurse"),
    Freq = c(155725, 243664)
    )

# Calculate margins for gender but with absolute totals
# Female: (155,725 * 0.65) + (243,664 * 0.98) = 339,912
# Male: (155,725 * 0.35) + (243,664 * 0.02) = 59,477

pop_gender <- 
  data.frame(
    scdm_2_rec = c("Female", "Male"),
    Freq = c(339912, 59477)
    )



svy_ua <- 
  svydesign(
    data = ds_ua,
    ids = ~loc_3,  # participants may be more similar within regions
    weights = NULL
    )

# raking is a good practice when applying convenience sampling
svy_ua_w <- rake(
  design = svy_ua,
  sample.margins = list(~work_2, ~scdm_2_rec),
  population.margins = list(pop_profession, pop_gender)
)



rm(pop_profession, pop_gender)

Tables

Sociodemographic

# tbl_svysummary has issues with stratifying, we can only gen information
# on separate columns

# define vars
scdm_vars <- c("scdm_1_rec", "scdm_4_dic", "scdm_5_dic", "work_1", 
               "work_3_rec", "work_5_rec", "conflict")


# We do this first so we can use them in the labels later
n_counts <- 
  ds_ua |> 
  count(work_2, scdm_2_rec)

n_total_counts <- 
  ds_ua |> 
  count(work_2) # For the Overall headers

get_n_style <- 
  function(w, g = NULL) {
    
    if(is.null(g)) {
      
      val <- 
        n_total_counts |> 
        filter(work_2 == w) |> 
        pull(n)
      
      } else {
        
        val <- 
          n_counts |> 
          filter(work_2 == w, 
                 scdm_2_rec == g) |> 
          pull(n)
  }
  style_number(val)
}

# Doctors
n_doc_all <- get_n_style("Doctor")
n_doc_m   <- get_n_style("Doctor", "Male")
n_doc_f   <- get_n_style("Doctor", "Female")

# Nurses
n_nur_all <- get_n_style("Nurse")
n_nur_m   <- get_n_style("Nurse", "Male")
n_nur_f   <- get_n_style("Nurse", "Female")


# Summaries (With add_overall) 

doc_n <- 
  ds_ua |> 
  filter(work_2 == "Doctor") |>
  tbl_summary(
    by = scdm_2_rec,
    include = all_of(scdm_vars),
    statistic = list(all_categorical() ~ "{n}"),
    missing = "no"
  ) |>
  add_overall() |> # Adds stat_0
  modify_header(all_stat_cols() ~ "**{level}** (n)") 

doc_p <- 
  subset(svy_ua_w, work_2 == "Doctor") |>
  tbl_svysummary(
    by = scdm_2_rec,
    include = all_of(scdm_vars),
    statistic = list(all_categorical() ~ "({p}%)"),
    missing = "no"
  ) |>
  add_overall() |> # Adds stat_0
  modify_header(all_stat_cols() ~ "**{level}** (%)")

doc_merged <- 
  tbl_merge(list(doc_n, doc_p), 
            tab_spanner = FALSE)


nur_n <- 
  ds_ua |> 
  filter(work_2 == "Nurse") |>
  tbl_summary(
    by = scdm_2_rec,
    include = all_of(scdm_vars),
    statistic = list(all_categorical() ~ "{n}"),
    missing = "no"
  ) |>
  add_overall() |>
  modify_header(all_stat_cols() ~ "**{level}** (n)")

nur_p <- 
  subset(svy_ua_w, work_2 == "Nurse") |>
  tbl_svysummary(
    by = scdm_2_rec,
    include = all_of(scdm_vars),
    statistic = list(all_categorical() ~ "({p}%)"),
    missing = "no"
  ) |>
  add_overall() |>
  modify_header(all_stat_cols() ~ "**{level}** (%)")

nur_merged <- 
  tbl_merge(list(nur_n, nur_p), 
            tab_spanner = FALSE)


# Merge and GT

scdm_tbl_w <- 
  
  tbl_merge(
    list(doc_merged, nur_merged),
    tab_spanner = c("**Doctor**", "**Nurse**")
  ) |>  
  modify_footnote(everything() ~ NA) |> 
  as_gt() 

# Column merging

# LOGIC:
# stat_0 = Overall
# stat_1 = Female (Alphabetical F < M)
# stat_2 = Male
#
# Suffixes added by tbl_merge:
# _1 = Counts (from the first merge n+p)
# _2 = Props  (from the first merge n+p)
# _1 (outer) = Doctors
# _2 (outer) = Nurses

scdm_tbl_w <- 
  scdm_tbl_w |>

  cols_merge(columns = c("stat_0_1_1", "stat_0_2_1")) |> 
  cols_merge(columns = c("stat_1_1_1", "stat_1_2_1")) |> 
  cols_merge(columns = c("stat_2_1_1", "stat_2_2_1")) |> 
  cols_merge(columns = c("stat_0_1_2", "stat_0_2_2")) |> 
  cols_merge(columns = c("stat_1_1_2", "stat_1_2_2")) |> 
  cols_merge(columns = c("stat_2_1_2", "stat_2_2_2")) |> 
  cols_label(
    stat_0_1_1 = md(glue::glue("**Overall**<br>N = {n_doc_all}")), 
    stat_1_1_1 = md(glue::glue("**Female**<br>N = {n_doc_f}")), 
    stat_2_1_1 = md(glue::glue("**Male**<br>N = {n_doc_m}")),
    stat_0_1_2 = md(glue::glue("**Overall**<br>N = {n_nur_all}")),
    stat_1_1_2 = md(glue::glue("**Female**<br>N = {n_nur_f}")),
    stat_2_1_2 = md(glue::glue("**Male**<br>N = {n_nur_m}"))
  ) |>
  tab_footnote(
    footnote = "n (weighted %)",
    locations = cells_column_labels(
      columns = c(stat_0_1_1, stat_1_1_1, stat_2_1_1, 
                  stat_0_1_2, stat_1_1_2, stat_2_1_2)
    )
  )

# View
scdm_tbl_w
Characteristic
Doctor
Nurse
Overall
N = 10,158
1
Female
N = 7,662
1
Male
N = 2,496
1
Overall
N = 13,579
1
Female
N = 12,744
1
Male
N = 835
1
Age groups (Recoded)











    20-30 1,694 (17%) 1,214 (16%) 480 (19%) 2,142 (16%) 1,866 (15%) 276 (33%)
    31-45 3,330 (33%) 2,567 (34%) 763 (31%) 5,181 (38%) 4,931 (39%) 250 (30%)
    46-55 2,063 (20%) 1,561 (20%) 502 (20%) 3,999 (29%) 3,793 (30%) 206 (25%)
    Over 55 3,071 (30%) 2,320 (30%) 751 (30%) 2,257 (17%) 2,154 (17%) 103 (12%)
Relationship status











    No partner 3,507 (34%) 2,843 (37%) 664 (27%) 4,541 (33%) 4,233 (33%) 308 (37%)
    Has a partner 6,639 (66%) 4,811 (63%) 1,828 (73%) 9,027 (67%) 8,500 (67%) 527 (63%)
Having children in the household











    Has children 6,449 (63%) 4,940 (65%) 1,509 (61%) 9,982 (73%) 9,497 (75%) 485 (58%)
    No children 3,692 (37%) 2,711 (35%) 981 (39%) 3,574 (27%) 3,224 (25%) 350 (42%)
Post-graduate training 1,026 (10%) 738 (9.7%) 288 (12%) 1,140 (8.5%) 1,026 (8.1%) 114 (14%)
Length of service (Recoded)











    5 years or less 1,836 (18%) 1,371 (18%) 465 (19%) 1,281 (9.7%) 1,087 (8.7%) 194 (24%)
    6-10 years 1,209 (12%) 885 (12%) 324 (13%) 1,431 (11%) 1,310 (10%) 121 (15%)
    More than 10 years 6,943 (69%) 5,272 (70%) 1,671 (68%) 10,613 (79%) 10,117 (81%) 496 (61%)
Healthcare setting (Recoded)











    Outpatient care 6,000 (60%) 4,935 (66%) 1,065 (43%) 5,703 (43%) 5,571 (45%) 132 (16%)
    In-hospital care 3,117 (32%) 2,054 (27%) 1,063 (43%) 5,030 (38%) 4,920 (40%) 110 (14%)
    Emergencies 835 (8.6%) 508 (6.8%) 327 (13%) 2,417 (19%) 1,856 (15%) 561 (70%)
Proximity to combat areas and occupied territories











    No conflict zone 8,440 (83%) 6,304 (82%) 2,136 (86%) 11,031 (81%) 10,345 (81%) 686 (82%)
    Conflict zone 1,718 (17%) 1,358 (18%) 360 (14%) 2,548 (19%) 2,399 (19%) 149 (18%)
1 n (weighted %)
# Save
gtsave(scdm_tbl_w, "out/tables/scdm_tbl_w.docx")

rm(n_counts, n_m_doc, n_m_nur, n_f_doc, n_f_nur, nur_n, nur_p,
   doc_merged, doc_n, doc_p, nur_merged)
# Run functions 
tbl_depression_w <- 
  generate_outcome_table_w_out("phq_co", "Probable Depression")
gtsave(tbl_depression_w, "out/tables/dep_by_scdm_w.docx")

tbl_anxiety_w <- 
  generate_outcome_table_w_out("gad_co", "Probable Anxiety")
gtsave(tbl_anxiety_w, "out/tables/anx_by_scdm_w.docx")

tbl_suicide_w <- 
  generate_outcome_table_w_out("suic_idea", "Passive Suicide Thoughts")
gtsave(tbl_suicide_w, "out/tables/suic_by_scdm_w.docx")


tbl_depression_w
Probable Depression
Doctor
Nurse
Male
(N = 2,129)
Female
(N = 6,431)
Overall
(N = 8,560)
Male
(N = 677)
Female
(N = 10,313)
Overall
(N = 10,990)
Overall
Overall 33.8% (30.9-36.8) 35.5% (33.4-37.7) 35.1% (33.1-37.1) 27.5% (22.8-32.5) 22.4% (20.1-24.9) 22.8% (20.4-25.3)
Age groups (Recoded)
20-30 46.1% (40.6-51.6) 48.3% (45.1-51.5) 47.6% (44.6-50.6) 34.8% (27.2-43.1) 32.7% (27.7-37.9) 33.0% (28.1-38.1)
31-45 45.8% (41.5-50.1) 42.3% (39.2-45.5) 43.2% (40.3-46.2) 29.9% (24.7-35.5) 23.8% (20.4-27.5) 24.2% (20.7-27.9)
46-55 27.4% (23.2-31.9) 36.2% (33.6-38.8) 33.8% (31.6-36.1) 23.7% (19.4-28.3) 22.3% (20.2-24.5) 22.4% (20.3-24.6)
Over 55 17.8% (15.1-20.8) 21.0% (18.7-23.5) 20.2% (18.0-22.4) 8.8% (3.7-17.0) 10.7% (9.0-12.7) 10.6% (8.8-12.7)
Relationship status
No partner 44.8% (40.0-49.7) 36.2% (33.6-38.9) 38.0% (35.6-40.5) 31.5% (23.9-39.9) 25.1% (23.2-27.1) 25.7% (23.7-27.7)
Has a partner 30.0% (26.6-33.4) 35.1% (33.1-37.2) 33.5% (31.5-35.6) 25.1% (20.3-30.3) 21.1% (18.4-24.0) 21.4% (18.6-24.3)
Having children in the household
Has children 29.8% (26.7-33.1) 33.6% (31.4-35.9) 32.6% (30.5-34.8) 25.6% (20.3-31.6) 21.3% (18.6-24.1) 21.5% (18.8-24.4)
No children 39.8% (35.4-44.4) 39.0% (36.4-41.7) 39.3% (36.8-41.7) 30.0% (22.4-38.6) 25.9% (24.0-27.9) 26.4% (24.4-28.5)
Post-graduate training
No 35.0% (31.9-38.1) 35.8% (33.8-37.9) 35.6% (33.6-37.6) 27.0% (21.7-32.8) 22.6% (20.0-25.3) 22.9% (20.2-25.6)
Yes 24.3% (19.5-29.7) 32.5% (25.6-40.0) 29.8% (24.5-35.6) 31.0% (17.4-47.6) 20.7% (17.4-24.3) 21.9% (18.4-25.7)
Length of service (Recoded)
5 years or less 42.3% (36.6-48.2) 45.2% (42.1-48.2) 44.3% (41.6-47.1) 34.0% (25.9-42.8) 32.3% (25.8-39.2) 32.6% (26.8-38.7)
6-10 years 51.1% (44.5-57.5) 47.7% (43.9-51.5) 48.7% (45.4-52.0) 32.3% (21.7-44.5) 27.0% (23.5-30.7) 27.5% (24.3-31.0)
More than 10 years 27.9% (25.0-31.0) 31.1% (28.8-33.4) 30.3% (28.1-32.5) 24.1% (21.1-27.3) 20.9% (18.6-23.3) 21.1% (18.8-23.5)
Healthcare setting (Recoded)
Outpatient care 32.9% (28.2-37.9) 34.9% (32.5-37.3) 34.5% (32.0-37.0) 25.9% (18.8-34.0) 22.8% (20.2-25.5) 22.9% (20.2-25.6)
In-hospital care 34.8% (31.6-38.1) 36.1% (33.9-38.3) 35.6% (33.7-37.6) 25.8% (16.9-36.5) 20.9% (18.2-23.8) 21.0% (18.3-24.0)
Emergencies 33.7% (22.1-46.9) 40.5% (31.4-50.1) 37.5% (27.7-48.2) 28.2% (23.4-33.4) 25.9% (22.3-29.7) 26.5% (23.0-30.2)
Proximity to combat areas and occupied territories
No conflict zone 33.8% (30.5-37.2) 35.5% (33.3-37.7) 35.0% (32.8-37.3) 26.3% (20.8-32.4) 21.9% (19.1-24.9) 22.2% (19.4-25.2)
Conflict zone 34.0% (26.6-42.0) 35.9% (28.6-43.8) 35.5% (29.5-41.8) 32.5% (27.9-37.4) 24.9% (21.6-28.4) 25.4% (22.5-28.5)
Weighted Prevalence (95% CI)
tbl_anxiety_w
Probable Anxiety
Doctor
Nurse
Male
(N = 2,134)
Female
(N = 6,438)
Overall
(N = 8,572)
Male
(N = 680)
Female
(N = 10,323)
Overall
(N = 11,003)
Overall
Overall 21.7% (19.6-23.9) 25.7% (24.0-27.4) 24.6% (23.1-26.1) 16.3% (12.0-21.5) 16.6% (14.7-18.6) 16.6% (14.7-18.5)
Age groups (Recoded)
20-30 29.3% (24.7-34.3) 36.5% (33.3-39.8) 34.2% (31.5-37.1) 20.1% (12.2-30.1) 24.2% (20.1-28.7) 23.6% (19.6-27.9)
31-45 29.2% (25.8-32.9) 30.9% (28.5-33.3) 30.4% (28.4-32.6) 18.0% (11.4-26.5) 16.6% (14.1-19.3) 16.6% (14.2-19.4)
46-55 17.7% (15.0-20.7) 25.7% (23.4-28.1) 23.5% (21.7-25.4) 13.0% (7.6-20.3) 16.9% (15.5-18.4) 16.7% (15.3-18.2)
Over 55 11.6% (9.0-14.7) 14.4% (12.7-16.2) 13.6% (11.9-15.5) 8.5% (2.8-18.9) 9.5% (7.9-11.2) 9.4% (7.9-11.1)
Relationship status
No partner 28.9% (24.5-33.5) 25.5% (23.4-27.7) 26.2% (24.3-28.3) 19.6% (13.1-27.7) 18.4% (16.8-20.2) 18.5% (16.7-20.4)
Has a partner 19.2% (16.9-21.7) 25.8% (23.9-27.7) 23.8% (22.2-25.4) 14.4% (10.4-19.1) 15.7% (13.4-18.2) 15.6% (13.4-18.0)
Having children in the household
Has children 19.3% (17.3-21.4) 23.9% (22.2-25.7) 22.7% (21.1-24.4) 14.1% (10.5-18.4) 15.8% (13.6-18.1) 15.7% (13.6-17.9)
No children 25.3% (21.5-29.5) 28.9% (26.9-30.9) 27.8% (26.2-29.6) 19.4% (11.9-29.1) 19.0% (17.4-20.7) 19.1% (17.3-21.0)
Post-graduate training
No 22.1% (19.9-24.4) 26.0% (24.2-27.8) 24.9% (23.4-26.5) 16.6% (12.2-21.8) 16.7% (14.6-18.9) 16.7% (14.7-18.9)
Yes 18.2% (14.0-23.1) 22.4% (18.5-26.7) 21.0% (18.0-24.3) 14.8% (4.5-32.7) 15.1% (12.5-18.0) 15.0% (11.9-18.6)
Length of service (Recoded)
5 years or less 26.4% (21.0-32.4) 33.8% (30.6-37.0) 31.7% (28.7-34.7) 19.0% (9.8-31.4) 24.5% (20.1-29.3) 23.5% (19.9-27.4)
6-10 years 32.0% (27.0-37.4) 35.4% (32.4-38.4) 34.4% (31.9-36.9) 19.0% (9.3-32.6) 20.1% (16.5-24.1) 20.0% (16.3-24.2)
More than 10 years 18.4% (16.3-20.7) 22.1% (20.2-24.0) 21.1% (19.4-22.8) 14.8% (12.0-18.0) 15.4% (13.7-17.2) 15.3% (13.7-17.1)
Healthcare setting (Recoded)
Outpatient care 22.1% (18.5-26.0) 25.9% (24.0-27.9) 25.2% (23.2-27.2) 16.1% (9.5-24.7) 17.4% (15.6-19.5) 17.4% (15.5-19.4)
In-hospital care 22.2% (19.3-25.2) 24.8% (22.8-26.8) 23.8% (22.3-25.3) 15.7% (7.8-27.0) 14.6% (12.5-17.0) 14.7% (12.5-17.0)
Emergencies 19.2% (13.0-26.7) 27.2% (21.9-33.1) 23.7% (18.3-29.8) 16.5% (11.2-23.1) 19.5% (16.9-22.3) 18.7% (15.7-22.0)
Proximity to combat areas and occupied territories
No conflict zone 21.8% (19.5-24.3) 25.4% (23.6-27.2) 24.4% (22.7-26.1) 15.5% (10.5-21.8) 15.9% (13.8-18.1) 15.9% (13.8-18.1)
Conflict zone 20.8% (15.5-27.0) 27.2% (22.4-32.4) 25.7% (22.4-29.3) 19.8% (12.8-28.6) 19.6% (16.7-22.7) 19.6% (16.6-22.9)
Weighted Prevalence (95% CI)
tbl_suicide_w
Passive Suicide Thoughts
Doctor
Nurse
Male
(N = 2,137)
Female
(N = 6,460)
Overall
(N = 8,597)
Male
(N = 682)
Female
(N = 10,367)
Overall
(N = 11,049)
Overall
Overall 15.2% (13.3-17.2) 11.4% (10.5-12.3) 12.4% (11.5-13.4) 12.6% (9.1-16.9) 8.0% (6.8-9.3) 8.3% (7.1-9.7)
Age groups (Recoded)
20-30 22.5% (18.3-27.2) 18.4% (16.2-20.6) 19.7% (17.6-21.9) 17.3% (11.1-25.3) 14.1% (11.4-17.1) 14.5% (11.8-17.7)
31-45 20.8% (16.6-25.4) 13.1% (11.4-15.1) 15.1% (13.2-17.3) 11.7% (7.1-17.8) 7.7% (6.3-9.2) 7.9% (6.5-9.4)
46-55 11.4% (8.8-14.5) 11.1% (9.8-12.5) 11.2% (10.0-12.6) 10.7% (5.7-17.6) 7.8% (6.6-9.3) 8.0% (6.7-9.4)
Over 55 7.3% (5.6-9.4) 6.0% (5.2-6.9) 6.4% (5.7-7.1) 6.0% (2.6-11.6) 3.8% (3.0-4.8) 3.9% (3.1-4.9)
Relationship status
No partner 21.7% (16.9-27.1) 13.5% (12.0-15.0) 15.2% (13.5-17.0) 16.0% (10.5-23.0) 10.5% (9.1-12.0) 10.9% (9.3-12.6)
Has a partner 13.0% (11.1-15.0) 10.2% (9.4-11.0) 11.0% (10.1-12.0) 10.6% (7.3-14.6) 6.8% (5.6-8.1) 7.0% (5.8-8.4)
Having children in the household
Has children 12.8% (11.5-14.2) 10.1% (9.4-10.9) 10.8% (10.2-11.5) 10.3% (6.9-14.7) 7.0% (5.8-8.4) 7.2% (6.0-8.5)
No children 18.9% (15.1-23.1) 13.6% (12.0-15.4) 15.2% (13.4-17.1) 15.8% (9.9-23.4) 10.8% (9.2-12.6) 11.4% (9.5-13.5)
Post-graduate training
No 15.1% (13.3-17.1) 11.2% (10.4-12.1) 12.3% (11.4-13.2) 12.3% (8.7-16.8) 7.9% (6.7-9.2) 8.2% (7.0-9.5)
Yes 15.9% (11.9-20.7) 12.8% (9.8-16.3) 13.8% (11.2-16.8) 14.8% (8.3-23.5) 9.4% (6.7-12.7) 10.1% (7.4-13.3)
Length of service (Recoded)
5 years or less 21.9% (17.3-27.0) 16.0% (13.8-18.4) 17.6% (15.5-19.9) 20.8% (13.4-29.9) 13.0% (9.7-16.8) 14.3% (11.0-18.2)
6-10 years 24.6% (18.9-31.0) 15.4% (13.1-18.1) 18.2% (15.9-20.6) 13.0% (6.1-23.2) 12.8% (10.2-15.9) 12.9% (10.3-15.8)
More than 10 years 11.6% (10.2-13.2) 9.6% (8.8-10.3) 10.1% (9.4-10.9) 9.6% (6.3-14.0) 6.9% (5.9-8.0) 7.0% (6.0-8.2)
Healthcare setting (Recoded)
Outpatient care 15.6% (12.6-18.9) 11.0% (10.2-12.0) 11.9% (10.8-13.1) 9.7% (4.7-17.3) 7.9% (6.7-9.2) 7.9% (6.7-9.3)
In-hospital care 15.6% (13.9-17.4) 11.1% (9.7-12.7) 12.8% (11.6-14.0) 10.1% (4.6-18.7) 7.2% (6.0-8.6) 7.3% (6.0-8.7)
Emergencies 13.0% (7.9-19.8) 15.7% (9.9-23.2) 14.5% (9.3-21.3) 13.8% (9.9-18.5) 10.5% (8.3-13.0) 11.4% (9.2-13.8)
Proximity to combat areas and occupied territories
No conflict zone 15.8% (13.6-18.2) 11.2% (10.2-12.3) 12.5% (11.4-13.7) 12.2% (7.9-17.9) 7.8% (6.4-9.3) 8.1% (6.6-9.8)
Conflict zone 11.6% (9.4-14.1) 12.1% (10.7-13.6) 12.0% (10.7-13.3) 14.3% (10.2-19.3) 8.8% (6.8-11.2) 9.2% (7.2-11.6)
Weighted Prevalence (95% CI)
# Generate tables with function
tbl_harassment_w <- generate_exposure_table_w_exp("work_30_dic", "Sexual harassment")
gtsave(tbl_harassment_w, "out/tables/harass_by_scdm_w.docx")

tbl_threats_w <- generate_exposure_table_w_exp("work_31_dic", "Violent threats")
gtsave(tbl_threats_w, "out/tables/threats_by_scdm_w.docx")

tbl_violence_w <- generate_exposure_table_w_exp("work_32_dic", "Physical violence")
gtsave(tbl_violence_w, "out/tables/violence_by_scdm_w.docx")

tbl_bullying_w <- generate_exposure_table_w_exp("work_33_dic", "Bullying")
gtsave(tbl_bullying_w, "out/tables/bullying_by_scdm_w.docx")

tbl_colleagues_w <- generate_exposure_table_w_exp("work_21_dic", "Colleague support")
gtsave(tbl_colleagues_w, "out/tables/col_supp_by_scdm_w.docx")

tbl_superiors_w <- generate_exposure_table_w_exp("work_22_dic", 
                                         "Support from superiors")
gtsave(tbl_superiors_w, "out/tables/sup_supp_by_scdm_w.docx")

tbl_meaning_w <- generate_exposure_table_w_exp("wb_wami_1_dic", "Meaning in work")
gtsave(tbl_meaning_w, "out/tables/meaning_by_scdm_w.docx")

tbl_purpose_w <- generate_exposure_table_w_exp("wb_wami_2_dic", "Purpose in work")
gtsave(tbl_purpose_w, "out/tables/purpose_by_scdm_w.docx")



# Visualize

tbl_harassment_w
Sexual harassment
Doctor
Nurse
Male
(N = 2,226)
Female
(N = 6,705)
Overall
(N = 8,931)
Male
(N = 716)
Female
(N = 10,765)
Overall
(N = 11,481)
Overall
Overall 8.2% (7.2-9.3) 9.8% (9.0-10.5) 9.3% (8.7-10.0) 8.8% (7.1-10.7) 6.8% (6.0-7.6) 6.9% (6.1-7.7)
Age groups (Recoded)
20-30 54.9% (48.6-61.2) 60.0% (57.1-62.9) 58.4% (55.8-61.0) 57.0% (50.3-63.5) 58.7% (55.8-61.6) 58.4% (55.6-61.2)
31-45 53.0% (48.9-57.1) 54.8% (52.7-57.0) 54.4% (52.7-56.0) 48.8% (41.1-56.6) 54.5% (52.9-56.1) 54.2% (52.5-55.8)
46-55 60.7% (57.3-64.1) 60.3% (57.2-63.4) 60.4% (58.0-62.9) 56.5% (47.6-65.1) 59.5% (57.9-61.2) 59.4% (58.0-60.7)
Over 55 65.8% (62.1-69.4) 65.0% (62.3-67.5) 65.2% (62.9-67.4) 58.2% (46.4-69.4) 64.4% (62.1-66.7) 64.1% (61.9-66.2)
Relationship status
No partner 54.1% (48.9-59.3) 60.0% (57.0-63.0) 58.8% (56.0-61.5) 54.9% (48.2-61.5) 58.0% (55.9-60.1) 57.7% (55.7-59.8)
Has a partner 60.4% (58.2-62.5) 59.7% (57.9-61.5) 59.9% (58.6-61.2) 54.4% (49.5-59.2) 58.4% (57.1-59.7) 58.1% (56.9-59.3)
Having children in the household
Has children 60.0% (57.7-62.3) 60.0% (57.9-62.0) 60.0% (58.5-61.5) 54.0% (48.7-59.2) 57.9% (56.5-59.3) 57.7% (56.4-59.0)
No children 56.7% (52.5-60.8) 59.5% (56.9-62.1) 58.7% (56.5-60.8) 55.4% (51.0-59.8) 59.3% (57.6-60.9) 58.8% (57.1-60.5)
Post-graduate training
No 59.2% (56.7-61.7) 60.0% (58.1-61.9) 59.8% (58.4-61.1) 54.0% (49.7-58.4) 58.7% (57.5-60.0) 58.4% (57.4-59.4)
Yes 55.0% (48.7-61.2) 58.4% (53.3-63.3) 57.2% (52.9-61.6) 57.7% (43.9-70.8) 52.2% (47.8-56.5) 52.8% (49.0-56.7)
Length of service (Recoded)
5 years or less 57.7% (52.6-62.8) 61.6% (58.4-64.7) 60.5% (58.0-62.9) 61.7% (51.7-71.0) 60.6% (56.6-64.4) 60.8% (56.6-64.9)
6-10 years 50.7% (44.1-57.2) 55.7% (50.3-61.0) 54.2% (49.2-59.1) 51.4% (35.6-66.9) 57.6% (54.2-61.0) 57.0% (53.7-60.3)
More than 10 years 60.5% (58.1-62.8) 60.1% (58.2-62.0) 60.2% (58.7-61.7) 53.0% (48.6-57.4) 58.1% (56.9-59.3) 57.8% (56.8-58.8)
Healthcare setting (Recoded)
Outpatient care 58.3% (54.8-61.7) 58.2% (56.0-60.4) 58.2% (56.5-59.9) 66.7% (56.3-76.0) 59.2% (57.2-61.1) 59.4% (57.5-61.2)
In-hospital care 59.6% (55.7-63.4) 63.1% (60.3-65.9) 61.8% (59.6-64.0) 57.0% (47.5-66.1) 57.8% (55.8-59.8) 57.8% (55.8-59.8)
Emergencies 57.6% (53.0-62.0) 62.2% (57.0-67.2) 60.2% (56.7-63.6) 51.4% (48.6-54.1) 56.9% (55.2-58.5) 55.4% (53.9-56.9)
Proximity to combat areas and occupied territories
No conflict zone 58.0% (55.4-60.5) 59.7% (57.5-61.9) 59.2% (57.6-60.8) 55.4% (50.8-60.0) 58.2% (56.9-59.6) 58.0% (56.9-59.2)
Conflict zone 63.2% (52.5-73.1) 60.5% (57.4-63.4) 61.1% (56.8-65.3) 50.8% (40.4-61.0) 58.3% (56.6-60.0) 57.8% (56.2-59.3)
Weighted Prevalence (95% CI)
tbl_threats_w
Violent threats
Doctor
Nurse
Male
(N = 2,218)
Female
(N = 6,689)
Overall
(N = 8,907)
Male
(N = 715)
Female
(N = 10,744)
Overall
(N = 11,459)
Overall
Overall 27.2% (24.0-30.6) 17.6% (15.6-19.8) 20.3% (18.3-22.4) 29.0% (23.1-35.4) 10.2% (8.3-12.5) 11.6% (9.2-14.4)
Age groups (Recoded)
20-30 54.9% (48.6-61.2) 60.0% (57.1-62.9) 58.4% (55.8-61.0) 57.0% (50.3-63.5) 58.7% (55.8-61.6) 58.4% (55.6-61.2)
31-45 53.0% (48.9-57.1) 54.8% (52.7-57.0) 54.4% (52.7-56.0) 48.8% (41.1-56.6) 54.5% (52.9-56.1) 54.2% (52.5-55.8)
46-55 60.7% (57.3-64.1) 60.3% (57.2-63.4) 60.4% (58.0-62.9) 56.5% (47.6-65.1) 59.5% (57.9-61.2) 59.4% (58.0-60.7)
Over 55 65.8% (62.1-69.4) 65.0% (62.3-67.5) 65.2% (62.9-67.4) 58.2% (46.4-69.4) 64.4% (62.1-66.7) 64.1% (61.9-66.2)
Relationship status
No partner 54.1% (48.9-59.3) 60.0% (57.0-63.0) 58.8% (56.0-61.5) 54.9% (48.2-61.5) 58.0% (55.9-60.1) 57.7% (55.7-59.8)
Has a partner 60.4% (58.2-62.5) 59.7% (57.9-61.5) 59.9% (58.6-61.2) 54.4% (49.5-59.2) 58.4% (57.1-59.7) 58.1% (56.9-59.3)
Having children in the household
Has children 60.0% (57.7-62.3) 60.0% (57.9-62.0) 60.0% (58.5-61.5) 54.0% (48.7-59.2) 57.9% (56.5-59.3) 57.7% (56.4-59.0)
No children 56.7% (52.5-60.8) 59.5% (56.9-62.1) 58.7% (56.5-60.8) 55.4% (51.0-59.8) 59.3% (57.6-60.9) 58.8% (57.1-60.5)
Post-graduate training
No 59.2% (56.7-61.7) 60.0% (58.1-61.9) 59.8% (58.4-61.1) 54.0% (49.7-58.4) 58.7% (57.5-60.0) 58.4% (57.4-59.4)
Yes 55.0% (48.7-61.2) 58.4% (53.3-63.3) 57.2% (52.9-61.6) 57.7% (43.9-70.8) 52.2% (47.8-56.5) 52.8% (49.0-56.7)
Length of service (Recoded)
5 years or less 57.7% (52.6-62.8) 61.6% (58.4-64.7) 60.5% (58.0-62.9) 61.7% (51.7-71.0) 60.6% (56.6-64.4) 60.8% (56.6-64.9)
6-10 years 50.7% (44.1-57.2) 55.7% (50.3-61.0) 54.2% (49.2-59.1) 51.4% (35.6-66.9) 57.6% (54.2-61.0) 57.0% (53.7-60.3)
More than 10 years 60.5% (58.1-62.8) 60.1% (58.2-62.0) 60.2% (58.7-61.7) 53.0% (48.6-57.4) 58.1% (56.9-59.3) 57.8% (56.8-58.8)
Healthcare setting (Recoded)
Outpatient care 58.3% (54.8-61.7) 58.2% (56.0-60.4) 58.2% (56.5-59.9) 66.7% (56.3-76.0) 59.2% (57.2-61.1) 59.4% (57.5-61.2)
In-hospital care 59.6% (55.7-63.4) 63.1% (60.3-65.9) 61.8% (59.6-64.0) 57.0% (47.5-66.1) 57.8% (55.8-59.8) 57.8% (55.8-59.8)
Emergencies 57.6% (53.0-62.0) 62.2% (57.0-67.2) 60.2% (56.7-63.6) 51.4% (48.6-54.1) 56.9% (55.2-58.5) 55.4% (53.9-56.9)
Proximity to combat areas and occupied territories
No conflict zone 58.0% (55.4-60.5) 59.7% (57.5-61.9) 59.2% (57.6-60.8) 55.4% (50.8-60.0) 58.2% (56.9-59.6) 58.0% (56.9-59.2)
Conflict zone 63.2% (52.5-73.1) 60.5% (57.4-63.4) 61.1% (56.8-65.3) 50.8% (40.4-61.0) 58.3% (56.6-60.0) 57.8% (56.2-59.3)
Weighted Prevalence (95% CI)
tbl_violence_w
Physical violence
Doctor
Nurse
Male
(N = 2,218)
Female
(N = 6,677)
Overall
(N = 8,895)
Male
(N = 713)
Female
(N = 10,733)
Overall
(N = 11,446)
Overall
Overall 5.5% (4.0-7.4) 2.5% (2.0-3.1) 3.3% (2.7-4.1) 10.9% (8.1-14.4) 3.1% (2.5-3.8) 3.7% (2.9-4.6)
Age groups (Recoded)
20-30 54.9% (48.6-61.2) 60.0% (57.1-62.9) 58.4% (55.8-61.0) 57.0% (50.3-63.5) 58.7% (55.8-61.6) 58.4% (55.6-61.2)
31-45 53.0% (48.9-57.1) 54.8% (52.7-57.0) 54.4% (52.7-56.0) 48.8% (41.1-56.6) 54.5% (52.9-56.1) 54.2% (52.5-55.8)
46-55 60.7% (57.3-64.1) 60.3% (57.2-63.4) 60.4% (58.0-62.9) 56.5% (47.6-65.1) 59.5% (57.9-61.2) 59.4% (58.0-60.7)
Over 55 65.8% (62.1-69.4) 65.0% (62.3-67.5) 65.2% (62.9-67.4) 58.2% (46.4-69.4) 64.4% (62.1-66.7) 64.1% (61.9-66.2)
Relationship status
No partner 54.1% (48.9-59.3) 60.0% (57.0-63.0) 58.8% (56.0-61.5) 54.9% (48.2-61.5) 58.0% (55.9-60.1) 57.7% (55.7-59.8)
Has a partner 60.4% (58.2-62.5) 59.7% (57.9-61.5) 59.9% (58.6-61.2) 54.4% (49.5-59.2) 58.4% (57.1-59.7) 58.1% (56.9-59.3)
Having children in the household
Has children 60.0% (57.7-62.3) 60.0% (57.9-62.0) 60.0% (58.5-61.5) 54.0% (48.7-59.2) 57.9% (56.5-59.3) 57.7% (56.4-59.0)
No children 56.7% (52.5-60.8) 59.5% (56.9-62.1) 58.7% (56.5-60.8) 55.4% (51.0-59.8) 59.3% (57.6-60.9) 58.8% (57.1-60.5)
Post-graduate training
No 59.2% (56.7-61.7) 60.0% (58.1-61.9) 59.8% (58.4-61.1) 54.0% (49.7-58.4) 58.7% (57.5-60.0) 58.4% (57.4-59.4)
Yes 55.0% (48.7-61.2) 58.4% (53.3-63.3) 57.2% (52.9-61.6) 57.7% (43.9-70.8) 52.2% (47.8-56.5) 52.8% (49.0-56.7)
Length of service (Recoded)
5 years or less 57.7% (52.6-62.8) 61.6% (58.4-64.7) 60.5% (58.0-62.9) 61.7% (51.7-71.0) 60.6% (56.6-64.4) 60.8% (56.6-64.9)
6-10 years 50.7% (44.1-57.2) 55.7% (50.3-61.0) 54.2% (49.2-59.1) 51.4% (35.6-66.9) 57.6% (54.2-61.0) 57.0% (53.7-60.3)
More than 10 years 60.5% (58.1-62.8) 60.1% (58.2-62.0) 60.2% (58.7-61.7) 53.0% (48.6-57.4) 58.1% (56.9-59.3) 57.8% (56.8-58.8)
Healthcare setting (Recoded)
Outpatient care 58.3% (54.8-61.7) 58.2% (56.0-60.4) 58.2% (56.5-59.9) 66.7% (56.3-76.0) 59.2% (57.2-61.1) 59.4% (57.5-61.2)
In-hospital care 59.6% (55.7-63.4) 63.1% (60.3-65.9) 61.8% (59.6-64.0) 57.0% (47.5-66.1) 57.8% (55.8-59.8) 57.8% (55.8-59.8)
Emergencies 57.6% (53.0-62.0) 62.2% (57.0-67.2) 60.2% (56.7-63.6) 51.4% (48.6-54.1) 56.9% (55.2-58.5) 55.4% (53.9-56.9)
Proximity to combat areas and occupied territories
No conflict zone 58.0% (55.4-60.5) 59.7% (57.5-61.9) 59.2% (57.6-60.8) 55.4% (50.8-60.0) 58.2% (56.9-59.6) 58.0% (56.9-59.2)
Conflict zone 63.2% (52.5-73.1) 60.5% (57.4-63.4) 61.1% (56.8-65.3) 50.8% (40.4-61.0) 58.3% (56.6-60.0) 57.8% (56.2-59.3)
Weighted Prevalence (95% CI)
tbl_bullying_w
Bullying
Doctor
Nurse
Male
(N = 2,218)
Female
(N = 6,670)
Overall
(N = 8,888)
Male
(N = 710)
Female
(N = 10,717)
Overall
(N = 11,427)
Overall
Overall 24.5% (21.6-27.5) 27.4% (26.0-28.7) 26.6% (25.3-27.9) 22.0% (18.6-25.7) 18.1% (16.6-19.6) 18.3% (17.0-19.7)
Age groups (Recoded)
20-30 54.9% (48.6-61.2) 60.0% (57.1-62.9) 58.4% (55.8-61.0) 57.0% (50.3-63.5) 58.7% (55.8-61.6) 58.4% (55.6-61.2)
31-45 53.0% (48.9-57.1) 54.8% (52.7-57.0) 54.4% (52.7-56.0) 48.8% (41.1-56.6) 54.5% (52.9-56.1) 54.2% (52.5-55.8)
46-55 60.7% (57.3-64.1) 60.3% (57.2-63.4) 60.4% (58.0-62.9) 56.5% (47.6-65.1) 59.5% (57.9-61.2) 59.4% (58.0-60.7)
Over 55 65.8% (62.1-69.4) 65.0% (62.3-67.5) 65.2% (62.9-67.4) 58.2% (46.4-69.4) 64.4% (62.1-66.7) 64.1% (61.9-66.2)
Relationship status
No partner 54.1% (48.9-59.3) 60.0% (57.0-63.0) 58.8% (56.0-61.5) 54.9% (48.2-61.5) 58.0% (55.9-60.1) 57.7% (55.7-59.8)
Has a partner 60.4% (58.2-62.5) 59.7% (57.9-61.5) 59.9% (58.6-61.2) 54.4% (49.5-59.2) 58.4% (57.1-59.7) 58.1% (56.9-59.3)
Having children in the household
Has children 60.0% (57.7-62.3) 60.0% (57.9-62.0) 60.0% (58.5-61.5) 54.0% (48.7-59.2) 57.9% (56.5-59.3) 57.7% (56.4-59.0)
No children 56.7% (52.5-60.8) 59.5% (56.9-62.1) 58.7% (56.5-60.8) 55.4% (51.0-59.8) 59.3% (57.6-60.9) 58.8% (57.1-60.5)
Post-graduate training
No 59.2% (56.7-61.7) 60.0% (58.1-61.9) 59.8% (58.4-61.1) 54.0% (49.7-58.4) 58.7% (57.5-60.0) 58.4% (57.4-59.4)
Yes 55.0% (48.7-61.2) 58.4% (53.3-63.3) 57.2% (52.9-61.6) 57.7% (43.9-70.8) 52.2% (47.8-56.5) 52.8% (49.0-56.7)
Length of service (Recoded)
5 years or less 57.7% (52.6-62.8) 61.6% (58.4-64.7) 60.5% (58.0-62.9) 61.7% (51.7-71.0) 60.6% (56.6-64.4) 60.8% (56.6-64.9)
6-10 years 50.7% (44.1-57.2) 55.7% (50.3-61.0) 54.2% (49.2-59.1) 51.4% (35.6-66.9) 57.6% (54.2-61.0) 57.0% (53.7-60.3)
More than 10 years 60.5% (58.1-62.8) 60.1% (58.2-62.0) 60.2% (58.7-61.7) 53.0% (48.6-57.4) 58.1% (56.9-59.3) 57.8% (56.8-58.8)
Healthcare setting (Recoded)
Outpatient care 58.3% (54.8-61.7) 58.2% (56.0-60.4) 58.2% (56.5-59.9) 66.7% (56.3-76.0) 59.2% (57.2-61.1) 59.4% (57.5-61.2)
In-hospital care 59.6% (55.7-63.4) 63.1% (60.3-65.9) 61.8% (59.6-64.0) 57.0% (47.5-66.1) 57.8% (55.8-59.8) 57.8% (55.8-59.8)
Emergencies 57.6% (53.0-62.0) 62.2% (57.0-67.2) 60.2% (56.7-63.6) 51.4% (48.6-54.1) 56.9% (55.2-58.5) 55.4% (53.9-56.9)
Proximity to combat areas and occupied territories
No conflict zone 58.0% (55.4-60.5) 59.7% (57.5-61.9) 59.2% (57.6-60.8) 55.4% (50.8-60.0) 58.2% (56.9-59.6) 58.0% (56.9-59.2)
Conflict zone 63.2% (52.5-73.1) 60.5% (57.4-63.4) 61.1% (56.8-65.3) 50.8% (40.4-61.0) 58.3% (56.6-60.0) 57.8% (56.2-59.3)
Weighted Prevalence (95% CI)
tbl_colleagues_w
Colleague support
Doctor
Nurse
Male
(N = 2,259)
Female
(N = 6,804)
Overall
(N = 9,063)
Male
(N = 729)
Female
(N = 11,007)
Overall
(N = 11,736)
Overall
Overall 58.7% (56.3-61.1) 59.8% (58.0-61.6) 59.5% (58.1-60.9) 54.6% (50.7-58.5) 58.3% (57.2-59.3) 58.0% (57.0-59.0)
Age groups (Recoded)
20-30 54.9% (48.6-61.2) 60.0% (57.1-62.9) 58.4% (55.8-61.0) 57.0% (50.3-63.5) 58.7% (55.8-61.6) 58.4% (55.6-61.2)
31-45 53.0% (48.9-57.1) 54.8% (52.7-57.0) 54.4% (52.7-56.0) 48.8% (41.1-56.6) 54.5% (52.9-56.1) 54.2% (52.5-55.8)
46-55 60.7% (57.3-64.1) 60.3% (57.2-63.4) 60.4% (58.0-62.9) 56.5% (47.6-65.1) 59.5% (57.9-61.2) 59.4% (58.0-60.7)
Over 55 65.8% (62.1-69.4) 65.0% (62.3-67.5) 65.2% (62.9-67.4) 58.2% (46.4-69.4) 64.4% (62.1-66.7) 64.1% (61.9-66.2)
Relationship status
No partner 54.1% (48.9-59.3) 60.0% (57.0-63.0) 58.8% (56.0-61.5) 54.9% (48.2-61.5) 58.0% (55.9-60.1) 57.7% (55.7-59.8)
Has a partner 60.4% (58.2-62.5) 59.7% (57.9-61.5) 59.9% (58.6-61.2) 54.4% (49.5-59.2) 58.4% (57.1-59.7) 58.1% (56.9-59.3)
Having children in the household
Has children 60.0% (57.7-62.3) 60.0% (57.9-62.0) 60.0% (58.5-61.5) 54.0% (48.7-59.2) 57.9% (56.5-59.3) 57.7% (56.4-59.0)
No children 56.7% (52.5-60.8) 59.5% (56.9-62.1) 58.7% (56.5-60.8) 55.4% (51.0-59.8) 59.3% (57.6-60.9) 58.8% (57.1-60.5)
Post-graduate training
No 59.2% (56.7-61.7) 60.0% (58.1-61.9) 59.8% (58.4-61.1) 54.0% (49.7-58.4) 58.7% (57.5-60.0) 58.4% (57.4-59.4)
Yes 55.0% (48.7-61.2) 58.4% (53.3-63.3) 57.2% (52.9-61.6) 57.7% (43.9-70.8) 52.2% (47.8-56.5) 52.8% (49.0-56.7)
Length of service (Recoded)
5 years or less 57.7% (52.6-62.8) 61.6% (58.4-64.7) 60.5% (58.0-62.9) 61.7% (51.7-71.0) 60.6% (56.6-64.4) 60.8% (56.6-64.9)
6-10 years 50.7% (44.1-57.2) 55.7% (50.3-61.0) 54.2% (49.2-59.1) 51.4% (35.6-66.9) 57.6% (54.2-61.0) 57.0% (53.7-60.3)
More than 10 years 60.5% (58.1-62.8) 60.1% (58.2-62.0) 60.2% (58.7-61.7) 53.0% (48.6-57.4) 58.1% (56.9-59.3) 57.8% (56.8-58.8)
Healthcare setting (Recoded)
Outpatient care 58.3% (54.8-61.7) 58.2% (56.0-60.4) 58.2% (56.5-59.9) 66.7% (56.3-76.0) 59.2% (57.2-61.1) 59.4% (57.5-61.2)
In-hospital care 59.6% (55.7-63.4) 63.1% (60.3-65.9) 61.8% (59.6-64.0) 57.0% (47.5-66.1) 57.8% (55.8-59.8) 57.8% (55.8-59.8)
Emergencies 57.6% (53.0-62.0) 62.2% (57.0-67.2) 60.2% (56.7-63.6) 51.4% (48.6-54.1) 56.9% (55.2-58.5) 55.4% (53.9-56.9)
Proximity to combat areas and occupied territories
No conflict zone 58.0% (55.4-60.5) 59.7% (57.5-61.9) 59.2% (57.6-60.8) 55.4% (50.8-60.0) 58.2% (56.9-59.6) 58.0% (56.9-59.2)
Conflict zone 63.2% (52.5-73.1) 60.5% (57.4-63.4) 61.1% (56.8-65.3) 50.8% (40.4-61.0) 58.3% (56.6-60.0) 57.8% (56.2-59.3)
Weighted Prevalence (95% CI)
tbl_superiors_w
Support from superiors
Doctor
Nurse
Male
(N = 2,255)
Female
(N = 6,793)
Overall
(N = 9,048)
Male
(N = 729)
Female
(N = 10,974)
Overall
(N = 11,703)
Overall
Overall 49.5% (47.4-51.6) 52.7% (50.4-55.1) 51.8% (49.9-53.8) 48.7% (44.6-52.8) 51.2% (49.3-53.1) 51.1% (49.3-52.8)
Age groups (Recoded)
20-30 54.9% (48.6-61.2) 60.0% (57.1-62.9) 58.4% (55.8-61.0) 57.0% (50.3-63.5) 58.7% (55.8-61.6) 58.4% (55.6-61.2)
31-45 53.0% (48.9-57.1) 54.8% (52.7-57.0) 54.4% (52.7-56.0) 48.8% (41.1-56.6) 54.5% (52.9-56.1) 54.2% (52.5-55.8)
46-55 60.7% (57.3-64.1) 60.3% (57.2-63.4) 60.4% (58.0-62.9) 56.5% (47.6-65.1) 59.5% (57.9-61.2) 59.4% (58.0-60.7)
Over 55 65.8% (62.1-69.4) 65.0% (62.3-67.5) 65.2% (62.9-67.4) 58.2% (46.4-69.4) 64.4% (62.1-66.7) 64.1% (61.9-66.2)
Relationship status
No partner 54.1% (48.9-59.3) 60.0% (57.0-63.0) 58.8% (56.0-61.5) 54.9% (48.2-61.5) 58.0% (55.9-60.1) 57.7% (55.7-59.8)
Has a partner 60.4% (58.2-62.5) 59.7% (57.9-61.5) 59.9% (58.6-61.2) 54.4% (49.5-59.2) 58.4% (57.1-59.7) 58.1% (56.9-59.3)
Having children in the household
Has children 60.0% (57.7-62.3) 60.0% (57.9-62.0) 60.0% (58.5-61.5) 54.0% (48.7-59.2) 57.9% (56.5-59.3) 57.7% (56.4-59.0)
No children 56.7% (52.5-60.8) 59.5% (56.9-62.1) 58.7% (56.5-60.8) 55.4% (51.0-59.8) 59.3% (57.6-60.9) 58.8% (57.1-60.5)
Post-graduate training
No 59.2% (56.7-61.7) 60.0% (58.1-61.9) 59.8% (58.4-61.1) 54.0% (49.7-58.4) 58.7% (57.5-60.0) 58.4% (57.4-59.4)
Yes 55.0% (48.7-61.2) 58.4% (53.3-63.3) 57.2% (52.9-61.6) 57.7% (43.9-70.8) 52.2% (47.8-56.5) 52.8% (49.0-56.7)
Length of service (Recoded)
5 years or less 57.7% (52.6-62.8) 61.6% (58.4-64.7) 60.5% (58.0-62.9) 61.7% (51.7-71.0) 60.6% (56.6-64.4) 60.8% (56.6-64.9)
6-10 years 50.7% (44.1-57.2) 55.7% (50.3-61.0) 54.2% (49.2-59.1) 51.4% (35.6-66.9) 57.6% (54.2-61.0) 57.0% (53.7-60.3)
More than 10 years 60.5% (58.1-62.8) 60.1% (58.2-62.0) 60.2% (58.7-61.7) 53.0% (48.6-57.4) 58.1% (56.9-59.3) 57.8% (56.8-58.8)
Healthcare setting (Recoded)
Outpatient care 58.3% (54.8-61.7) 58.2% (56.0-60.4) 58.2% (56.5-59.9) 66.7% (56.3-76.0) 59.2% (57.2-61.1) 59.4% (57.5-61.2)
In-hospital care 59.6% (55.7-63.4) 63.1% (60.3-65.9) 61.8% (59.6-64.0) 57.0% (47.5-66.1) 57.8% (55.8-59.8) 57.8% (55.8-59.8)
Emergencies 57.6% (53.0-62.0) 62.2% (57.0-67.2) 60.2% (56.7-63.6) 51.4% (48.6-54.1) 56.9% (55.2-58.5) 55.4% (53.9-56.9)
Proximity to combat areas and occupied territories
No conflict zone 58.0% (55.4-60.5) 59.7% (57.5-61.9) 59.2% (57.6-60.8) 55.4% (50.8-60.0) 58.2% (56.9-59.6) 58.0% (56.9-59.2)
Conflict zone 63.2% (52.5-73.1) 60.5% (57.4-63.4) 61.1% (56.8-65.3) 50.8% (40.4-61.0) 58.3% (56.6-60.0) 57.8% (56.2-59.3)
Weighted Prevalence (95% CI)
tbl_meaning_w
Meaning in work
Doctor
Nurse
Male
(N = 1,718)
Female
(N = 5,289)
Overall
(N = 7,007)
Male
(N = 525)
Female
(N = 8,186)
Overall
(N = 8,711)
Overall
Overall 81.3% (78.7-83.6) 84.5% (82.6-86.2) 83.6% (81.8-85.2) 68.6% (64.7-72.3) 80.6% (79.4-81.8) 79.8% (78.7-80.9)
Age groups (Recoded)
20-30 54.9% (48.6-61.2) 60.0% (57.1-62.9) 58.4% (55.8-61.0) 57.0% (50.3-63.5) 58.7% (55.8-61.6) 58.4% (55.6-61.2)
31-45 53.0% (48.9-57.1) 54.8% (52.7-57.0) 54.4% (52.7-56.0) 48.8% (41.1-56.6) 54.5% (52.9-56.1) 54.2% (52.5-55.8)
46-55 60.7% (57.3-64.1) 60.3% (57.2-63.4) 60.4% (58.0-62.9) 56.5% (47.6-65.1) 59.5% (57.9-61.2) 59.4% (58.0-60.7)
Over 55 65.8% (62.1-69.4) 65.0% (62.3-67.5) 65.2% (62.9-67.4) 58.2% (46.4-69.4) 64.4% (62.1-66.7) 64.1% (61.9-66.2)
Relationship status
No partner 54.1% (48.9-59.3) 60.0% (57.0-63.0) 58.8% (56.0-61.5) 54.9% (48.2-61.5) 58.0% (55.9-60.1) 57.7% (55.7-59.8)
Has a partner 60.4% (58.2-62.5) 59.7% (57.9-61.5) 59.9% (58.6-61.2) 54.4% (49.5-59.2) 58.4% (57.1-59.7) 58.1% (56.9-59.3)
Having children in the household
Has children 60.0% (57.7-62.3) 60.0% (57.9-62.0) 60.0% (58.5-61.5) 54.0% (48.7-59.2) 57.9% (56.5-59.3) 57.7% (56.4-59.0)
No children 56.7% (52.5-60.8) 59.5% (56.9-62.1) 58.7% (56.5-60.8) 55.4% (51.0-59.8) 59.3% (57.6-60.9) 58.8% (57.1-60.5)
Post-graduate training
No 59.2% (56.7-61.7) 60.0% (58.1-61.9) 59.8% (58.4-61.1) 54.0% (49.7-58.4) 58.7% (57.5-60.0) 58.4% (57.4-59.4)
Yes 55.0% (48.7-61.2) 58.4% (53.3-63.3) 57.2% (52.9-61.6) 57.7% (43.9-70.8) 52.2% (47.8-56.5) 52.8% (49.0-56.7)
Length of service (Recoded)
5 years or less 57.7% (52.6-62.8) 61.6% (58.4-64.7) 60.5% (58.0-62.9) 61.7% (51.7-71.0) 60.6% (56.6-64.4) 60.8% (56.6-64.9)
6-10 years 50.7% (44.1-57.2) 55.7% (50.3-61.0) 54.2% (49.2-59.1) 51.4% (35.6-66.9) 57.6% (54.2-61.0) 57.0% (53.7-60.3)
More than 10 years 60.5% (58.1-62.8) 60.1% (58.2-62.0) 60.2% (58.7-61.7) 53.0% (48.6-57.4) 58.1% (56.9-59.3) 57.8% (56.8-58.8)
Healthcare setting (Recoded)
Outpatient care 58.3% (54.8-61.7) 58.2% (56.0-60.4) 58.2% (56.5-59.9) 66.7% (56.3-76.0) 59.2% (57.2-61.1) 59.4% (57.5-61.2)
In-hospital care 59.6% (55.7-63.4) 63.1% (60.3-65.9) 61.8% (59.6-64.0) 57.0% (47.5-66.1) 57.8% (55.8-59.8) 57.8% (55.8-59.8)
Emergencies 57.6% (53.0-62.0) 62.2% (57.0-67.2) 60.2% (56.7-63.6) 51.4% (48.6-54.1) 56.9% (55.2-58.5) 55.4% (53.9-56.9)
Proximity to combat areas and occupied territories
No conflict zone 58.0% (55.4-60.5) 59.7% (57.5-61.9) 59.2% (57.6-60.8) 55.4% (50.8-60.0) 58.2% (56.9-59.6) 58.0% (56.9-59.2)
Conflict zone 63.2% (52.5-73.1) 60.5% (57.4-63.4) 61.1% (56.8-65.3) 50.8% (40.4-61.0) 58.3% (56.6-60.0) 57.8% (56.2-59.3)
Weighted Prevalence (95% CI)
tbl_purpose_w
Purpose in work
Doctor
Nurse
Male
(N = 1,806)
Female
(N = 5,558)
Overall
(N = 7,364)
Male
(N = 587)
Female
(N = 8,906)
Overall
(N = 9,493)
Overall
Overall 87.7% (85.7-89.4) 90.7% (89.5-91.8) 89.9% (88.7-91.0) 84.7% (81.8-87.2) 89.2% (88.4-90.0) 88.9% (88.1-89.7)
Age groups (Recoded)
20-30 54.9% (48.6-61.2) 60.0% (57.1-62.9) 58.4% (55.8-61.0) 57.0% (50.3-63.5) 58.7% (55.8-61.6) 58.4% (55.6-61.2)
31-45 53.0% (48.9-57.1) 54.8% (52.7-57.0) 54.4% (52.7-56.0) 48.8% (41.1-56.6) 54.5% (52.9-56.1) 54.2% (52.5-55.8)
46-55 60.7% (57.3-64.1) 60.3% (57.2-63.4) 60.4% (58.0-62.9) 56.5% (47.6-65.1) 59.5% (57.9-61.2) 59.4% (58.0-60.7)
Over 55 65.8% (62.1-69.4) 65.0% (62.3-67.5) 65.2% (62.9-67.4) 58.2% (46.4-69.4) 64.4% (62.1-66.7) 64.1% (61.9-66.2)
Relationship status
No partner 54.1% (48.9-59.3) 60.0% (57.0-63.0) 58.8% (56.0-61.5) 54.9% (48.2-61.5) 58.0% (55.9-60.1) 57.7% (55.7-59.8)
Has a partner 60.4% (58.2-62.5) 59.7% (57.9-61.5) 59.9% (58.6-61.2) 54.4% (49.5-59.2) 58.4% (57.1-59.7) 58.1% (56.9-59.3)
Having children in the household
Has children 60.0% (57.7-62.3) 60.0% (57.9-62.0) 60.0% (58.5-61.5) 54.0% (48.7-59.2) 57.9% (56.5-59.3) 57.7% (56.4-59.0)
No children 56.7% (52.5-60.8) 59.5% (56.9-62.1) 58.7% (56.5-60.8) 55.4% (51.0-59.8) 59.3% (57.6-60.9) 58.8% (57.1-60.5)
Post-graduate training
No 59.2% (56.7-61.7) 60.0% (58.1-61.9) 59.8% (58.4-61.1) 54.0% (49.7-58.4) 58.7% (57.5-60.0) 58.4% (57.4-59.4)
Yes 55.0% (48.7-61.2) 58.4% (53.3-63.3) 57.2% (52.9-61.6) 57.7% (43.9-70.8) 52.2% (47.8-56.5) 52.8% (49.0-56.7)
Length of service (Recoded)
5 years or less 57.7% (52.6-62.8) 61.6% (58.4-64.7) 60.5% (58.0-62.9) 61.7% (51.7-71.0) 60.6% (56.6-64.4) 60.8% (56.6-64.9)
6-10 years 50.7% (44.1-57.2) 55.7% (50.3-61.0) 54.2% (49.2-59.1) 51.4% (35.6-66.9) 57.6% (54.2-61.0) 57.0% (53.7-60.3)
More than 10 years 60.5% (58.1-62.8) 60.1% (58.2-62.0) 60.2% (58.7-61.7) 53.0% (48.6-57.4) 58.1% (56.9-59.3) 57.8% (56.8-58.8)
Healthcare setting (Recoded)
Outpatient care 58.3% (54.8-61.7) 58.2% (56.0-60.4) 58.2% (56.5-59.9) 66.7% (56.3-76.0) 59.2% (57.2-61.1) 59.4% (57.5-61.2)
In-hospital care 59.6% (55.7-63.4) 63.1% (60.3-65.9) 61.8% (59.6-64.0) 57.0% (47.5-66.1) 57.8% (55.8-59.8) 57.8% (55.8-59.8)
Emergencies 57.6% (53.0-62.0) 62.2% (57.0-67.2) 60.2% (56.7-63.6) 51.4% (48.6-54.1) 56.9% (55.2-58.5) 55.4% (53.9-56.9)
Proximity to combat areas and occupied territories
No conflict zone 58.0% (55.4-60.5) 59.7% (57.5-61.9) 59.2% (57.6-60.8) 55.4% (50.8-60.0) 58.2% (56.9-59.6) 58.0% (56.9-59.2)
Conflict zone 63.2% (52.5-73.1) 60.5% (57.4-63.4) 61.1% (56.8-65.3) 50.8% (40.4-61.0) 58.3% (56.6-60.0) 57.8% (56.2-59.3)
Weighted Prevalence (95% CI)

Exposures

# Generate table
table_all_exposures_w <- gen_w_exp_tbl(exposures)

gtsave(table_all_exposures_w, "out/tables/all_exp_tbl_w.docx")

table_all_exposures_w
Exposure
Doctor
Nurse
Female
(N = 7,662)
Male
(N = 2,496)
Overall
(N = 10,158)
Female
(N = 12,744)
Male
(N = 835)
Overall
(N = 13,579)
Risk factor
Bullying 27.4% (26.0-28.7) 24.5% (21.6-27.5) 26.6% (25.3-27.9) 18.1% (16.6-19.6) 22.0% (18.6-25.7) 18.3% (17.0-19.7)
Sexual Harassment 9.8% (9.0-10.5) 8.2% (7.2-9.3) 9.3% (8.7-10.0) 6.8% (6.0-7.6) 8.8% (7.1-10.7) 6.9% (6.1-7.7)
Violent threats 17.6% (15.6-19.8) 27.2% (24.0-30.6) 20.3% (18.3-22.4) 10.2% (8.3-12.5) 29.0% (23.1-35.4) 11.6% (9.2-14.4)
Physical violence 2.5% (2.0-3.1) 5.5% (4.0-7.4) 3.3% (2.7-4.1) 3.1% (2.5-3.8) 10.9% (8.1-14.4) 3.7% (2.9-4.6)
Protective factor
Colleague support 59.8% (58.0-61.6) 58.7% (56.3-61.1) 59.5% (58.1-60.9) 58.3% (57.2-59.3) 54.6% (50.7-58.5) 58.0% (57.0-59.0)
Support from superiors 52.7% (50.4-55.1) 49.5% (47.4-51.6) 51.8% (49.9-53.8) 51.2% (49.3-53.1) 48.7% (44.6-52.8) 51.1% (49.3-52.8)
Meaning in work 84.5% (82.6-86.2) 81.3% (78.7-83.6) 83.6% (81.8-85.2) 80.6% (79.4-81.8) 68.6% (64.7-72.3) 79.8% (78.7-80.9)
Purpose in work 90.7% (89.5-91.8) 87.7% (85.7-89.4) 89.9% (88.7-91.0) 89.2% (88.4-90.0) 84.7% (81.8-87.2) 88.9% (88.1-89.7)
Weighted Prevalence (95% CI)

Outcomes

# Generate table
table_all_outcomes_w <- gen_w_out_tbl(outcomes)

gtsave(table_all_outcomes_w, "out/tables/all_out_tbl_w.docx")

table_all_outcomes_w
Outcome
Doctor
Nurse
Male
(N = 2,496)
Female
(N = 7,662)
Overall
(N = 10,158)
Male
(N = 835)
Female
(N = 12,744)
Overall
(N = 13,579)
Probable Depression (PHQ-9) 33.8% (30.9-36.8) 35.5% (33.4-37.7) 35.1% (33.1-37.1) 27.5% (22.8-32.5) 22.4% (20.1-24.9) 22.8% (20.4-25.3)
Probable Anxiety (GAD-7) 21.7% (19.6-23.9) 25.7% (24.0-27.4) 24.6% (23.1-26.1) 16.3% (12.0-21.5) 16.6% (14.7-18.6) 16.6% (14.7-18.5)
Passive suicide thoughts (Item 9 of PHQ-9) 15.2% (13.3-17.2) 11.4% (10.5-12.3) 12.4% (11.5-13.4) 12.6% (9.1-16.9) 8.0% (6.8-9.3) 8.3% (7.1-9.7)
Unweighted Prevalence (95% CI). PHQ-9: 9-item Patient Health Questionnaire, a cut-off score ≥ 10 is defined for detecting probable depression. GAD-7: 7 item anxiety scale, a cut-off score ≥ 10 is defined for detecting probable anxiety. Any positive answer in the 9th item of the PHQ-9 is considered as having passive suicide thoughts.

Svy Models

# generate the grid for all possible combinations
tasks_grid <- expand_grid(
  outcome = outcomes,
  exposure = names(exposure_map),
  profession = c("Doctor", "Nurse")
)

# run function 
pwalk(
  list(tasks_grid$outcome, 
       tasks_grid$exposure, 
       tasks_grid$profession),
  function(out, exp, prof) {
    message(glue("Running: {out} vs {exp} ({prof})..."))
    run_svy_models(out, exp, prof, svy_ua_w)
  }
)
## Running: phq_co vs work_21_dic (Doctor)...
## Loading from disk: svy_dep_cols_doc_cr
## Loading from disk: svy_dep_cols_doc_str
## Loading from disk: svy_dep_cols_doc_adj
## Running: phq_co vs work_21_dic (Nurse)...
## Loading from disk: svy_dep_cols_nur_cr
## Loading from disk: svy_dep_cols_nur_str
## Loading from disk: svy_dep_cols_nur_adj
## Running: phq_co vs work_22_dic (Doctor)...
## Loading from disk: svy_dep_sup_doc_cr
## Loading from disk: svy_dep_sup_doc_str
## Loading from disk: svy_dep_sup_doc_adj
## Running: phq_co vs work_22_dic (Nurse)...
## Loading from disk: svy_dep_sup_nur_cr
## Loading from disk: svy_dep_sup_nur_str
## Loading from disk: svy_dep_sup_nur_adj
## Running: phq_co vs work_30_dic (Doctor)...
## Loading from disk: svy_dep_har_doc_cr
## Loading from disk: svy_dep_har_doc_str
## Loading from disk: svy_dep_har_doc_adj
## Running: phq_co vs work_30_dic (Nurse)...
## Loading from disk: svy_dep_har_nur_cr
## Loading from disk: svy_dep_har_nur_str
## Loading from disk: svy_dep_har_nur_adj
## Running: phq_co vs work_33_dic (Doctor)...
## Loading from disk: svy_dep_bul_doc_cr
## Loading from disk: svy_dep_bul_doc_str
## Loading from disk: svy_dep_bul_doc_adj
## Running: phq_co vs work_33_dic (Nurse)...
## Loading from disk: svy_dep_bul_nur_cr
## Loading from disk: svy_dep_bul_nur_str
## Loading from disk: svy_dep_bul_nur_adj
## Running: phq_co vs work_31_dic (Doctor)...
## Loading from disk: svy_dep_threats_doc_cr
## Loading from disk: svy_dep_threats_doc_str
## Loading from disk: svy_dep_threats_doc_adj
## Running: phq_co vs work_31_dic (Nurse)...
## Loading from disk: svy_dep_threats_nur_cr
## Loading from disk: svy_dep_threats_nur_str
## Loading from disk: svy_dep_threats_nur_adj
## Running: phq_co vs work_32_dic (Doctor)...
## Loading from disk: svy_dep_viol_doc_cr
## Loading from disk: svy_dep_viol_doc_str
## Loading from disk: svy_dep_viol_doc_adj
## Running: phq_co vs work_32_dic (Nurse)...
## Loading from disk: svy_dep_viol_nur_cr
## Loading from disk: svy_dep_viol_nur_str
## Loading from disk: svy_dep_viol_nur_adj
## Running: phq_co vs wb_wami_1_dic (Doctor)...
## Loading from disk: svy_dep_mean_doc_cr
## Loading from disk: svy_dep_mean_doc_str
## Loading from disk: svy_dep_mean_doc_adj
## Running: phq_co vs wb_wami_1_dic (Nurse)...
## Loading from disk: svy_dep_mean_nur_cr
## Loading from disk: svy_dep_mean_nur_str
## Loading from disk: svy_dep_mean_nur_adj
## Running: phq_co vs wb_wami_2_dic (Doctor)...
## Loading from disk: svy_dep_purp_doc_cr
## Loading from disk: svy_dep_purp_doc_str
## Loading from disk: svy_dep_purp_doc_adj
## Running: phq_co vs wb_wami_2_dic (Nurse)...
## Loading from disk: svy_dep_purp_nur_cr
## Loading from disk: svy_dep_purp_nur_str
## Loading from disk: svy_dep_purp_nur_adj
## Running: gad_co vs work_21_dic (Doctor)...
## Loading from disk: svy_anx_cols_doc_cr
## Loading from disk: svy_anx_cols_doc_str
## Loading from disk: svy_anx_cols_doc_adj
## Running: gad_co vs work_21_dic (Nurse)...
## Loading from disk: svy_anx_cols_nur_cr
## Loading from disk: svy_anx_cols_nur_str
## Loading from disk: svy_anx_cols_nur_adj
## Running: gad_co vs work_22_dic (Doctor)...
## Loading from disk: svy_anx_sup_doc_cr
## Loading from disk: svy_anx_sup_doc_str
## Loading from disk: svy_anx_sup_doc_adj
## Running: gad_co vs work_22_dic (Nurse)...
## Loading from disk: svy_anx_sup_nur_cr
## Loading from disk: svy_anx_sup_nur_str
## Loading from disk: svy_anx_sup_nur_adj
## Running: gad_co vs work_30_dic (Doctor)...
## Loading from disk: svy_anx_har_doc_cr
## Loading from disk: svy_anx_har_doc_str
## Loading from disk: svy_anx_har_doc_adj
## Running: gad_co vs work_30_dic (Nurse)...
## Loading from disk: svy_anx_har_nur_cr
## Loading from disk: svy_anx_har_nur_str
## Loading from disk: svy_anx_har_nur_adj
## Running: gad_co vs work_33_dic (Doctor)...
## Loading from disk: svy_anx_bul_doc_cr
## Loading from disk: svy_anx_bul_doc_str
## Loading from disk: svy_anx_bul_doc_adj
## Running: gad_co vs work_33_dic (Nurse)...
## Loading from disk: svy_anx_bul_nur_cr
## Loading from disk: svy_anx_bul_nur_str
## Loading from disk: svy_anx_bul_nur_adj
## Running: gad_co vs work_31_dic (Doctor)...
## Loading from disk: svy_anx_threats_doc_cr
## Loading from disk: svy_anx_threats_doc_str
## Loading from disk: svy_anx_threats_doc_adj
## Running: gad_co vs work_31_dic (Nurse)...
## Loading from disk: svy_anx_threats_nur_cr
## Loading from disk: svy_anx_threats_nur_str
## Loading from disk: svy_anx_threats_nur_adj
## Running: gad_co vs work_32_dic (Doctor)...
## Loading from disk: svy_anx_viol_doc_cr
## Loading from disk: svy_anx_viol_doc_str
## Loading from disk: svy_anx_viol_doc_adj
## Running: gad_co vs work_32_dic (Nurse)...
## Loading from disk: svy_anx_viol_nur_cr
## Loading from disk: svy_anx_viol_nur_str
## Loading from disk: svy_anx_viol_nur_adj
## Running: gad_co vs wb_wami_1_dic (Doctor)...
## Loading from disk: svy_anx_mean_doc_cr
## Loading from disk: svy_anx_mean_doc_str
## Loading from disk: svy_anx_mean_doc_adj
## Running: gad_co vs wb_wami_1_dic (Nurse)...
## Loading from disk: svy_anx_mean_nur_cr
## Loading from disk: svy_anx_mean_nur_str
## Loading from disk: svy_anx_mean_nur_adj
## Running: gad_co vs wb_wami_2_dic (Doctor)...
## Loading from disk: svy_anx_purp_doc_cr
## Loading from disk: svy_anx_purp_doc_str
## Loading from disk: svy_anx_purp_doc_adj
## Running: gad_co vs wb_wami_2_dic (Nurse)...
## Loading from disk: svy_anx_purp_nur_cr
## Loading from disk: svy_anx_purp_nur_str
## Loading from disk: svy_anx_purp_nur_adj
## Running: suic_idea vs work_21_dic (Doctor)...
## Loading from disk: svy_suic_cols_doc_cr
## Loading from disk: svy_suic_cols_doc_str
## Loading from disk: svy_suic_cols_doc_adj
## Running: suic_idea vs work_21_dic (Nurse)...
## Loading from disk: svy_suic_cols_nur_cr
## Loading from disk: svy_suic_cols_nur_str
## Loading from disk: svy_suic_cols_nur_adj
## Running: suic_idea vs work_22_dic (Doctor)...
## Loading from disk: svy_suic_sup_doc_cr
## Loading from disk: svy_suic_sup_doc_str
## Loading from disk: svy_suic_sup_doc_adj
## Running: suic_idea vs work_22_dic (Nurse)...
## Loading from disk: svy_suic_sup_nur_cr
## Loading from disk: svy_suic_sup_nur_str
## Loading from disk: svy_suic_sup_nur_adj
## Running: suic_idea vs work_30_dic (Doctor)...
## Loading from disk: svy_suic_har_doc_cr
## Loading from disk: svy_suic_har_doc_str
## Loading from disk: svy_suic_har_doc_adj
## Running: suic_idea vs work_30_dic (Nurse)...
## Loading from disk: svy_suic_har_nur_cr
## Loading from disk: svy_suic_har_nur_str
## Loading from disk: svy_suic_har_nur_adj
## Running: suic_idea vs work_33_dic (Doctor)...
## Loading from disk: svy_suic_bul_doc_cr
## Loading from disk: svy_suic_bul_doc_str
## Loading from disk: svy_suic_bul_doc_adj
## Running: suic_idea vs work_33_dic (Nurse)...
## Loading from disk: svy_suic_bul_nur_cr
## Loading from disk: svy_suic_bul_nur_str
## Loading from disk: svy_suic_bul_nur_adj
## Running: suic_idea vs work_31_dic (Doctor)...
## Loading from disk: svy_suic_threats_doc_cr
## Loading from disk: svy_suic_threats_doc_str
## Loading from disk: svy_suic_threats_doc_adj
## Running: suic_idea vs work_31_dic (Nurse)...
## Loading from disk: svy_suic_threats_nur_cr
## Loading from disk: svy_suic_threats_nur_str
## Loading from disk: svy_suic_threats_nur_adj
## Running: suic_idea vs work_32_dic (Doctor)...
## Loading from disk: svy_suic_viol_doc_cr
## Loading from disk: svy_suic_viol_doc_str
## Loading from disk: svy_suic_viol_doc_adj
## Running: suic_idea vs work_32_dic (Nurse)...
## Loading from disk: svy_suic_viol_nur_cr
## Loading from disk: svy_suic_viol_nur_str
## Loading from disk: svy_suic_viol_nur_adj
## Running: suic_idea vs wb_wami_1_dic (Doctor)...
## Loading from disk: svy_suic_mean_doc_cr
## Loading from disk: svy_suic_mean_doc_str
## Loading from disk: svy_suic_mean_doc_adj
## Running: suic_idea vs wb_wami_1_dic (Nurse)...
## Loading from disk: svy_suic_mean_nur_cr
## Loading from disk: svy_suic_mean_nur_str
## Loading from disk: svy_suic_mean_nur_adj
## Running: suic_idea vs wb_wami_2_dic (Doctor)...
## Loading from disk: svy_suic_purp_doc_cr
## Loading from disk: svy_suic_purp_doc_str
## Loading from disk: svy_suic_purp_doc_adj
## Running: suic_idea vs wb_wami_2_dic (Nurse)...
## Loading from disk: svy_suic_purp_nur_cr
## Loading from disk: svy_suic_purp_nur_str
## Loading from disk: svy_suic_purp_nur_adj

Survey results table

# find svy objects
svy_model_names <- ls(pattern = "^svy_", envir = .GlobalEnv)

# Extraction
survey_results_df <- 
  map_dfr(svy_model_names, function(obj_name) {
  
  # Load the model object
  model <- get(obj_name, envir = .GlobalEnv)
  
  # decode filename
  parts <- str_split(obj_name, "_")[[1]]
  
  out_code   <- parts[2]
  exp_code   <- parts[3]
  prof_code  <- parts[4]
  type_code  <- parts[5]
  
  # Decode Labels for the Table
  outcome_label <- case_when(
    out_code == "dep"  ~ "Depression",
    out_code == "anx"  ~ "Anxiety",
    out_code == "suic" ~ "Suicide thoughts"
  )
  
  exposure_label <- case_when(
    exp_code == "cols"    ~ "Colleague support",
    exp_code == "sup"     ~ "Support from superiors",
    exp_code == "har"     ~ "Sexual Harassment",
    exp_code == "bul"     ~ "Bullying",
    exp_code == "threats" ~ "Violent threats",
    exp_code == "viol"    ~ "Physical violence",
    exp_code == "mean"    ~ "Meaning in work",
    exp_code == "purp"    ~ "Purpose in work"
  )
  
  profession_label <- ifelse(prof_code == "doc", "Doctor", "Nurse")
  
  model_label <- case_when(
    type_code == "cr"  ~ "Crude",
    type_code == "str" ~ "Partially",
    type_code == "adj" ~ "Fully Adj."
  )
  
 
  term_lookup <- case_when(
    exp_code == "cols"    ~ "work_21_dicYes",
    exp_code == "sup"     ~ "work_22_dicYes",
    exp_code == "har"     ~ "work_30_dicYes",
    exp_code == "bul"     ~ "work_33_dicYes",
    exp_code == "threats" ~ "work_31_dicYes",
    exp_code == "viol"    ~ "work_32_dicYes",
    exp_code == "mean"    ~ "wb_wami_1_dicYes",
    exp_code == "purp"    ~ "wb_wami_2_dicYes"
  )
  
  # extract stats
  res <- tryCatch({
    
    # Check family
    is_logistic <- model$family$family %in% c("quasipoisson", "binomial")
    
    # Try to tidy
    tidy(model, conf.int = TRUE, exponentiate = is_logistic)
    
  }, error = function(e) {
    # If it fails, print the culprit and return NULL
    warning(paste("FAILED model:", obj_name, "-", e$message))
    return(NULL)
  })
  
  if (is.null(res)) return(NULL)
  
  # exposure term
  target_row <- 
    res |> 
    filter(term == term_lookup)
  
  if(nrow(target_row) > 0) {
    # If multiple rows match (rare), take the first one
    est  <- target_row$estimate[1]
    low  <- target_row$conf.low[1]
    high <- target_row$conf.high[1]
    
    
    # calculate absolute risks/means
    dat <- model$model
    
    exp_var_name <- str_remove(term_lookup, "Yes$")
    resp_var_name <- names(dat)[1]
    
    x_vec <- as.character(dat[[exp_var_name]])
    y_raw <- as.numeric(dat[[resp_var_name]])
    
    if (is.factor(y_raw)) {
       # Ensure it is 0 and 1
       y_vec <- as.numeric(as.character(y_raw)) 
    } else {
       y_vec <- as.numeric(y_raw)
    }
    
    if (is_logistic) {
      # Normalize 1/2 to 0/1 if necessary
      if(max(y_vec, na.rm = TRUE) > 1) y_vec <- y_vec - 1
      
      # Calculate %
      risk_unexp <- mean(y_vec[x_vec == "No"], na.rm = TRUE) * 100
      risk_exp   <- mean(y_vec[x_vec == "Yes"], na.rm = TRUE) * 100
      
      risk_unexp_str <- sprintf("%.1f%%", risk_unexp)
      risk_exp_str   <- sprintf("%.1f%%", risk_exp)
      
      } else {
        
        # Calculate Mean
        mean_unexp <- mean(y_vec[x_vec == "No"], na.rm = TRUE)
        mean_exp   <- mean(y_vec[x_vec == "Yes"], na.rm = TRUE)
        
        risk_unexp_str <- sprintf("%.2f", mean_unexp)
        risk_exp_str   <- sprintf("%.2f", mean_exp)
        }
    
    tibble(
      Outcome = outcome_label,
      Exposure = exposure_label,
      Profession = profession_label,
      Model = model_label,
      Type = ifelse(is_logistic, 
                    "PR", 
                    "Beta"),
      Est_CI = sprintf("%.2f (%.2f, %.2f)", est, low, high),
      Risk_Unexposed = risk_unexp_str,
      Risk_Exposed = risk_exp_str
    )
    
  } else {
    return(NULL)
  }
})


survey_results_df
## # A tibble: 144 × 8
##    Outcome Exposure    Profession Model Type  Est_CI Risk_Unexposed Risk_Exposed
##    <chr>   <chr>       <chr>      <chr> <chr> <chr>  <chr>          <chr>       
##  1 Anxiety Bullying    Doctor     Full… PR    2.11 … 14.9%          38.9%       
##  2 Anxiety Bullying    Doctor     Crude PR    2.33 … 14.8%          38.9%       
##  3 Anxiety Bullying    Doctor     Part… PR    2.10 … 14.8%          38.9%       
##  4 Anxiety Bullying    Nurse      Full… PR    2.69 … 14.9%          38.9%       
##  5 Anxiety Bullying    Nurse      Crude PR    2.82 … 14.8%          38.9%       
##  6 Anxiety Bullying    Nurse      Part… PR    2.68 … 14.8%          38.9%       
##  7 Anxiety Colleague … Doctor     Full… PR    0.65 … 26.4%          15.9%       
##  8 Anxiety Colleague … Doctor     Crude PR    0.62 … 26.3%          15.8%       
##  9 Anxiety Colleague … Doctor     Part… PR    0.65 … 26.3%          15.8%       
## 10 Anxiety Colleague … Nurse      Full… PR    0.58 … 26.4%          15.9%       
## # ℹ 134 more rows
# Save
saveRDS(survey_results_df, "out/dataframes/svy_results_df.rds")
writexl::write_xlsx(survey_results_df, "out/dataframes/svy_results_df.xlsx")

# generate table
tbl_svy_res <- build_svy_gt(
  survey_results_df, 
  metric_type = "PR", 
  title_text = "**Survey Logistic Models (PR)**", 
  footnote_text = "Weighted Prevalence Ratios (95% CI)"
)


gtsave(tbl_svy_res, "out/tables/svy_res_tbl.docx")


tbl_svy_res
Survey Logistic Models (PR)
Doctor
Nurse
Crude1 Partially adjusted2 Fully adjusted3 Crude1 Partially adjusted2 Fully adjusted3
Depression
Bullying 2.23 (2.13, 2.33) 2.03 (1.93, 2.13) 2.03 (1.93, 2.14) 2.69 (2.45, 2.96) 2.53 (2.26, 2.83) 2.53 (2.26, 2.83)
Sexual Harassment 1.78 (1.66, 1.90) 1.48 (1.38, 1.60) 1.49 (1.39, 1.61) 2.41 (2.21, 2.63) 2.10 (1.90, 2.33) 2.11 (1.91, 2.33)
Violent threats 2.00 (1.89, 2.12) 1.85 (1.74, 1.97) 1.86 (1.75, 1.98) 2.33 (2.16, 2.51) 2.17 (2.01, 2.33) 2.17 (2.05, 2.31)
Physical violence 1.67 (1.46, 1.91) 1.49 (1.30, 1.71) 1.50 (1.30, 1.72) 2.30 (2.07, 2.56) 2.09 (1.86, 2.35) 2.08 (1.87, 2.33)
Colleague support 0.63 (0.59, 0.67) 0.66 (0.61, 0.71) 0.66 (0.61, 0.71) 0.58 (0.55, 0.62) 0.60 (0.56, 0.64) 0.60 (0.55, 0.64)
Support from superiors 0.58 (0.54, 0.63) 0.62 (0.57, 0.67) 0.62 (0.57, 0.67) 0.50 (0.46, 0.55) 0.52 (0.48, 0.57) 0.52 (0.47, 0.57)
Meaning in work 0.48 (0.45, 0.51) 0.50 (0.47, 0.53) 0.50 (0.47, 0.53) 0.42 (0.38, 0.46) 0.44 (0.40, 0.48) 0.44 (0.40, 0.49)
Purpose in work 0.45 (0.42, 0.48) 0.48 (0.45, 0.51) 0.48 (0.45, 0.51) 0.46 (0.43, 0.49) 0.48 (0.45, 0.52) 0.49 (0.45, 0.53)
Anxiety
Bullying 2.33 (2.18, 2.49) 2.10 (1.96, 2.26) 2.11 (1.96, 2.28) 2.82 (2.57, 3.09) 2.68 (2.42, 2.98) 2.69 (2.42, 2.99)
Sexual Harassment 1.96 (1.82, 2.11) 1.61 (1.48, 1.76) 1.62 (1.49, 1.77) 2.55 (2.21, 2.95) 2.29 (1.97, 2.65) 2.30 (1.99, 2.65)
Violent threats 2.06 (1.90, 2.23) 1.92 (1.77, 2.09) 1.94 (1.77, 2.11) 2.39 (2.17, 2.63) 2.30 (2.12, 2.50) 2.31 (2.17, 2.47)
Physical violence 1.93 (1.71, 2.19) 1.75 (1.56, 1.97) 1.81 (1.60, 2.04) 2.30 (1.93, 2.74) 2.17 (1.82, 2.57) 2.18 (1.84, 2.58)
Colleague support 0.62 (0.59, 0.66) 0.65 (0.61, 0.69) 0.65 (0.61, 0.69) 0.57 (0.52, 0.63) 0.58 (0.52, 0.64) 0.58 (0.52, 0.64)
Support from superiors 0.56 (0.52, 0.61) 0.60 (0.55, 0.64) 0.59 (0.55, 0.64) 0.50 (0.46, 0.55) 0.52 (0.47, 0.57) 0.51 (0.47, 0.57)
Meaning in work 0.47 (0.44, 0.51) 0.49 (0.45, 0.53) 0.49 (0.45, 0.54) 0.46 (0.41, 0.51) 0.47 (0.42, 0.53) 0.47 (0.42, 0.54)
Purpose in work 0.44 (0.40, 0.48) 0.46 (0.42, 0.51) 0.47 (0.42, 0.52) 0.49 (0.44, 0.55) 0.50 (0.44, 0.57) 0.51 (0.45, 0.58)
Suicide thoughts
Bullying 2.49 (2.22, 2.79) 2.22 (1.96, 2.51) 2.22 (1.95, 2.53) 3.47 (2.96, 4.07) 3.20 (2.72, 3.77) 3.17 (2.69, 3.74)
Sexual Harassment 2.62 (2.45, 2.80) 2.16 (2.00, 2.32) 2.15 (1.99, 2.32) 3.35 (2.81, 3.99) 2.83 (2.36, 3.40) 2.80 (2.34, 3.36)
Violent threats 2.48 (2.21, 2.79) 2.17 (1.93, 2.43) 2.18 (1.94, 2.44) 2.98 (2.52, 3.52) 2.67 (2.21, 3.23) 2.63 (2.18, 3.16)
Physical violence 2.83 (2.51, 3.19) 2.31 (2.04, 2.63) 2.35 (1.99, 2.77) 3.23 (2.60, 4.01) 2.77 (2.17, 3.54) 2.74 (2.13, 3.53)
Colleague support 0.60 (0.54, 0.67) 0.64 (0.57, 0.71) 0.64 (0.57, 0.71) 0.51 (0.44, 0.60) 0.52 (0.45, 0.61) 0.52 (0.45, 0.61)
Support from superiors 0.56 (0.49, 0.65) 0.61 (0.53, 0.70) 0.61 (0.53, 0.71) 0.54 (0.45, 0.63) 0.56 (0.47, 0.66) 0.55 (0.47, 0.65)
Meaning in work 0.40 (0.34, 0.47) 0.43 (0.37, 0.50) 0.44 (0.38, 0.51) 0.45 (0.39, 0.51) 0.47 (0.41, 0.54) 0.47 (0.41, 0.54)
Purpose in work 0.35 (0.30, 0.40) 0.38 (0.33, 0.45) 0.39 (0.34, 0.45) 0.41 (0.37, 0.47) 0.44 (0.39, 0.50) 0.44 (0.39, 0.50)
Weighted Prevalence Ratios (95% CI)
1 No covariates included.
2 Adjusted by Gender, Age group and Proximity to combat areas and occupied territories .
3 Partially adjusted models plus specific covariates: Bullying and sexual harassment adjusted by Healthcare setting, Post-graduate training and Length of service. Violent threats and physical violence adjusted by Healthcare setting. Support from colleagues or superiors adjusted by Healthcare setting and Length of service. Finding meaning or purpose in job adjusted by Healthcare setting, Relationship status, Having children, and Length of service.
ls() |> 
  str_subset("^svy_") |> 
  rm(list = _)

rm(build_svy_gt, run_svy_models)

Bayesian Approach

Define priors

get_prior(
  formula = phq_co ~ scdm_1_rec + scdm_2_rec + scdm_4_dic + scdm_5_dic + work_5_rec + work_3_rec + work_1 + work_2 + (1 | loc_3),  # The random effect for region
  data = ds_ua,
  family = poisson(link = "log")
)
##                    prior     class                      coef group resp dpar
##                   (flat)         b                                          
##                   (flat)         b           scdm_1_rec31M45                
##                   (flat)         b           scdm_1_rec46M55                
##                   (flat)         b          scdm_1_recOver55                
##                   (flat)         b            scdm_2_recMale                
##                   (flat)         b     scdm_4_dicHasapartner                
##                   (flat)         b      scdm_5_dicNochildren                
##                   (flat)         b                 work_1Yes                
##                   (flat)         b               work_2Nurse                
##                   (flat)         b       work_3_rec6M10years                
##                   (flat)         b work_3_recMorethan10years                
##                   (flat)         b     work_5_recEmergencies                
##                   (flat)         b work_5_recInMhospitalcare                
##  student_t(3, -2.3, 2.5) Intercept                                          
##     student_t(3, 0, 2.5)        sd                                          
##     student_t(3, 0, 2.5)        sd                           loc_3          
##     student_t(3, 0, 2.5)        sd                 Intercept loc_3          
##  nlpar lb ub tag       source
##                       default
##                  (vectorized)
##                  (vectorized)
##                  (vectorized)
##                  (vectorized)
##                  (vectorized)
##                  (vectorized)
##                  (vectorized)
##                  (vectorized)
##                  (vectorized)
##                  (vectorized)
##                  (vectorized)
##                  (vectorized)
##                       default
##         0             default
##         0        (vectorized)
##         0        (vectorized)
# set list of priors.

bin_priors <- c(
  # Intercept MUST be negative
  # Mean -1.5 is ~ 22% prevalence (exp(-1.5))
  # SD 1 allows range from -2.5 to -0.5 (~ 8 to 60%)
  # Prevents model crashing 
  prior(normal(-1.5, 1), class = Intercept),  # vague prior for intercept
  
  # 0.5 allows risk ratios up to ~ 2.7, which is realistic
  prior(normal(0, 0.5), class = b),          # weak prior for predictors
  prior(student_t(3, 0, 1), class = sd)    # weak prior for random effect variance
)



# use stan as backend engine, newer, lighter, faster than default rstan
options(brms.backend = "cmdstanr")
options(mc.cores = 4) # forces it to always run 4 simultaneous cores

Models

Aggregated

# define covariates and outcomes

outcomes_list_agg <- c("phq_co", "gad_co")

# for model 2 in each
covars_str_agg <- c("conflict", "scdm_1_rec", "scdm_2_rec", "work_2")

# specific

covars_harbul <- c("work_5_rec", "work_1", "work_3_rec")
  
covars_viol <- c("work_5_rec")

# assign covariates to each exposure
exposure_map_agg <- list(
  
  "work_30_dic" = covars_harbul,
  "work_33_dic" = covars_harbul,
  
  "work_31_dic" = covars_viol,
  "work_32_dic" = covars_viol
)

# Define outcome-exposure binomials for running function
brms_tasks_agg <- expand_grid(
  outcome = outcomes_list_agg,
  exposure = names(exposure_map_agg)
)

# Run
pwalk(
  list(brms_tasks_agg$outcome, brms_tasks_agg$exposure),
  function(out, exp) {
    run_brms_agg(
      outcome = out, 
      exposure = exp, 
      design_df = ds_ua,
      output_dir = "out/bayesian_models_agg"
    )
    }
  )
## Running aggregate model: bay_dep_har_agg_adj
## Running aggregate model: bay_dep_bul_agg_adj
## Running aggregate model: bay_dep_threats_agg_adj
## Running aggregate model: bay_dep_viol_agg_adj
## Running aggregate model: bay_anx_har_agg_adj
## Running aggregate model: bay_anx_bul_agg_adj
## Running aggregate model: bay_anx_threats_agg_adj
## Running aggregate model: bay_anx_viol_agg_adj
brm_model_names_agg <- ls(pattern = "^bay_", envir = .GlobalEnv)


brm_results_df_agg <- 
  map_dfr(brm_model_names_agg, function(obj_name) {
  
  model <- get(obj_name, envir = .GlobalEnv)
  
  # decode name
  parts <- str_split(obj_name, "_")[[1]]
  
  out_code <- parts[2]
  exp_code <- parts[3]
  prof_code <- parts[4]
  type_code <- parts[5]
  
  # decode elements
  outcome_label <- case_when(
    out_code == "dep"  ~ "Depression",
    out_code == "anx"  ~ "Anxiety"
  )
  
  exposure_label <- case_when(
    exp_code == "har"     ~ "Sexual Harassment",
    exp_code == "bul"     ~ "Bullying",
    exp_code == "threats" ~ "Violent threats",
    exp_code == "viol"    ~ "Physical violence",
    TRUE ~ exp_code
  )
  
  term_lookup <- case_when(
    exp_code == "har"     ~ "work_30_dicYes",
    exp_code == "bul"     ~ "work_33_dicYes",
    exp_code == "threats" ~ "work_31_dicYes",
    exp_code == "viol"    ~ "work_32_dicYes"
  )
  
  
  raw_col_name <- case_when(
    exp_code == "har"     ~ "work_30_dic",
    exp_code == "bul"     ~ "work_33_dic",
    exp_code == "threats" ~ "work_31_dic",
    exp_code == "viol"    ~ "work_32_dic"
  )
  
  
  is_poisson <- model$family$family %in% c("poisson", "binomial")
  
  res <- tidy(
    model,
    effects = "fixed",
    conf.int = TRUE,
    conf.level = 0.95,
    exponentiate = is_poisson
  )
  
  target_row <- 
    res |>
    filter(term == term_lookup)
  
  if(nrow(target_row) > 0) {
    est  <- target_row$estimate[1]
    low  <- target_row$conf.low[1]
    high <- target_row$conf.high[1]
    
    
    
    dat <- model$data
    
    # Check if we can find the columns
    # We look for the raw_col_name we defined above
    if (raw_col_name %in% names(dat)) {
      
      # Extract vectors
      x_vec <- as.numeric(dat[[raw_col_name]])
      # The response is usually the first column in brms data
      y_vec <- as.numeric(dat[[1]]) 
      
      if (is_poisson) {
        # Normalize y to 0/1 if it was imported as 1/2
        if(max(y_vec, na.rm=TRUE) > 1) y_vec <- y_vec - 1
        
        # Calculate Observed Percentages
        # Note: We check for "No" and "Yes" explicitly. 
        # If data is 0/1, change to "0" and "1"
        risk_unexp_val <- mean(y_vec[x_vec == 0], na.rm = TRUE)
        risk_exp_val   <- mean(y_vec[x_vec == 1], na.rm = TRUE)
        
        abs_risk_unexposed <- sprintf("%.1f%%", risk_unexp_val * 100)
        abs_risk_exposed   <- sprintf("%.1f%%", risk_exp_val * 100)
        
      } else {
        # Linear Mean
        mean_unexp_val <- mean(y_vec[x_vec == 0], na.rm = TRUE)
        mean_exp_val   <- mean(y_vec[x_vec == 1], na.rm = TRUE)
        
        abs_risk_unexposed <- sprintf("%.2f", mean_unexp_val)
        abs_risk_exposed   <- sprintf("%.2f", mean_exp_val)
      }
    } else {
      # Debugging: if it still fails, print what columns are actually there
      # warning(paste("Could not find column:", raw_col_name))
      abs_risk_unexposed <- NA
      abs_risk_exposed   <- NA
    }
    
    
    tibble(
      Outcome = outcome_label,
      Exposure = exposure_label,
      Profession = "Overall",
      Est_CI = sprintf("%.2f (%.2f, %.2f)", est, low, high),
      # ADDED: Include the calculated columns here
      Risk_Unexposed = abs_risk_unexposed,
      Risk_Exposed = abs_risk_exposed,
      Rhat = max(rhat(model), na.rm = TRUE)
    )
  } else {
    return(NULL)
  }
})
## Loading required namespace: rstan
brm_results_df_agg
## # A tibble: 8 × 7
##   Outcome    Exposure        Profession Est_CI Risk_Unexposed Risk_Exposed  Rhat
##   <chr>      <chr>           <chr>      <chr>  <chr>          <chr>        <dbl>
## 1 Anxiety    Bullying        Overall    2.34 … NaN%           14.9%         1.00
## 2 Anxiety    Sexual Harassm… Overall    1.87 … NaN%           18.3%         1.00
## 3 Anxiety    Violent threats Overall    2.05 … NaN%           16.8%         1.00
## 4 Anxiety    Physical viole… Overall    1.91 … NaN%           19.4%         1.00
## 5 Depression Bullying        Overall    2.22 … NaN%           21.2%         1.00
## 6 Depression Sexual Harassm… Overall    1.71 … NaN%           26.0%         1.00
## 7 Depression Violent threats Overall    1.94 … NaN%           23.8%         1.00
## 8 Depression Physical viole… Overall    1.72 … NaN%           27.4%         1.00
saveRDS(brm_results_df_agg, "out/dataframes/brm_results_agg.rds")
writexl::write_xlsx(brm_results_df_agg, "out/dataframes/brm_results_agg.xlsx")

ls() |> 
  str_subset("^bay_") |> 
  rm(list = _)

rm(brms_tasks_agg, brm_model_names_agg, run_brms_agg)

Stratified models

# test
# run_brms_pair(outcome = "phq_co", exposure = "work_21_dic", design_df = ds_ua)
# if it works, then

# Define outcome-exposure binomials for analysis
brms_tasks <- expand_grid(
  outcome = outcomes_list,
  exposure = names(exposure_map)
)

# Run
pwalk(
  list(brms_tasks$outcome, brms_tasks$exposure),
  function(out, exp) {
    run_brms_pair(
      outcome = out, 
      exposure = exp, 
      design_df = ds_ua,
      output_dir = "out/bayesian_models"
    )}
  )
## Running doctor model: bay_dep_cols_doc_cr
## Running doctor model: bay_dep_cols_doc_str
## Running doctor model: bay_dep_cols_doc_adj
## Running nurse model (Update): bay_dep_cols_nur_cr
## The desired updates require recompiling the model
## Running nurse model (Update): bay_dep_cols_nur_str
## The desired updates require recompiling the model
## Running nurse model (Update): bay_dep_cols_nur_adj
## The desired updates require recompiling the model
## Running doctor model: bay_dep_sup_doc_cr
## Running doctor model: bay_dep_sup_doc_str
## Running doctor model: bay_dep_sup_doc_adj
## Running nurse model (Update): bay_dep_sup_nur_cr
## The desired updates require recompiling the model
## Running nurse model (Update): bay_dep_sup_nur_str
## The desired updates require recompiling the model
## Running nurse model (Update): bay_dep_sup_nur_adj
## The desired updates require recompiling the model
## Running doctor model: bay_dep_har_doc_cr
## Running doctor model: bay_dep_har_doc_str
## Running doctor model: bay_dep_har_doc_adj
## Running nurse model (Update): bay_dep_har_nur_cr
## The desired updates require recompiling the model
## Running nurse model (Update): bay_dep_har_nur_str
## The desired updates require recompiling the model
## Running nurse model (Update): bay_dep_har_nur_adj
## The desired updates require recompiling the model
## Running doctor model: bay_dep_bul_doc_cr
## Running doctor model: bay_dep_bul_doc_str
## Running doctor model: bay_dep_bul_doc_adj
## Running nurse model (Update): bay_dep_bul_nur_cr
## The desired updates require recompiling the model
## Running nurse model (Update): bay_dep_bul_nur_str
## The desired updates require recompiling the model
## Running nurse model (Update): bay_dep_bul_nur_adj
## The desired updates require recompiling the model
## Running doctor model: bay_dep_threats_doc_cr
## Running doctor model: bay_dep_threats_doc_str
## Running doctor model: bay_dep_threats_doc_adj
## Running nurse model (Update): bay_dep_threats_nur_cr
## The desired updates require recompiling the model
## Running nurse model (Update): bay_dep_threats_nur_str
## The desired updates require recompiling the model
## Running nurse model (Update): bay_dep_threats_nur_adj
## The desired updates require recompiling the model
## Running doctor model: bay_dep_viol_doc_cr
## Running doctor model: bay_dep_viol_doc_str
## Running doctor model: bay_dep_viol_doc_adj
## Running nurse model (Update): bay_dep_viol_nur_cr
## The desired updates require recompiling the model
## Running nurse model (Update): bay_dep_viol_nur_str
## The desired updates require recompiling the model
## Running nurse model (Update): bay_dep_viol_nur_adj
## The desired updates require recompiling the model
## Running doctor model: bay_dep_mean_doc_cr
## Running doctor model: bay_dep_mean_doc_str
## Running doctor model: bay_dep_mean_doc_adj
## Running nurse model (Update): bay_dep_mean_nur_cr
## The desired updates require recompiling the model
## Running nurse model (Update): bay_dep_mean_nur_str
## The desired updates require recompiling the model
## Running nurse model (Update): bay_dep_mean_nur_adj
## The desired updates require recompiling the model
## Running doctor model: bay_dep_purp_doc_cr
## Running doctor model: bay_dep_purp_doc_str
## Running doctor model: bay_dep_purp_doc_adj
## Running nurse model (Update): bay_dep_purp_nur_cr
## The desired updates require recompiling the model
## Running nurse model (Update): bay_dep_purp_nur_str
## The desired updates require recompiling the model
## Running nurse model (Update): bay_dep_purp_nur_adj
## The desired updates require recompiling the model
## Running doctor model: bay_anx_cols_doc_cr
## Running doctor model: bay_anx_cols_doc_str
## Running doctor model: bay_anx_cols_doc_adj
## Running nurse model (Update): bay_anx_cols_nur_cr
## The desired updates require recompiling the model
## Running nurse model (Update): bay_anx_cols_nur_str
## The desired updates require recompiling the model
## Running nurse model (Update): bay_anx_cols_nur_adj
## The desired updates require recompiling the model
## Running doctor model: bay_anx_sup_doc_cr
## Running doctor model: bay_anx_sup_doc_str
## Running doctor model: bay_anx_sup_doc_adj
## Running nurse model (Update): bay_anx_sup_nur_cr
## The desired updates require recompiling the model
## Running nurse model (Update): bay_anx_sup_nur_str
## The desired updates require recompiling the model
## Running nurse model (Update): bay_anx_sup_nur_adj
## The desired updates require recompiling the model
## Running doctor model: bay_anx_har_doc_cr
## Running doctor model: bay_anx_har_doc_str
## Running doctor model: bay_anx_har_doc_adj
## Running nurse model (Update): bay_anx_har_nur_cr
## The desired updates require recompiling the model
## Running nurse model (Update): bay_anx_har_nur_str
## The desired updates require recompiling the model
## Running nurse model (Update): bay_anx_har_nur_adj
## The desired updates require recompiling the model
## Running doctor model: bay_anx_bul_doc_cr
## Running doctor model: bay_anx_bul_doc_str
## Running doctor model: bay_anx_bul_doc_adj
## Running nurse model (Update): bay_anx_bul_nur_cr
## The desired updates require recompiling the model
## Running nurse model (Update): bay_anx_bul_nur_str
## The desired updates require recompiling the model
## Running nurse model (Update): bay_anx_bul_nur_adj
## The desired updates require recompiling the model
## Running doctor model: bay_anx_threats_doc_cr
## Running doctor model: bay_anx_threats_doc_str
## Running doctor model: bay_anx_threats_doc_adj
## Running nurse model (Update): bay_anx_threats_nur_cr
## The desired updates require recompiling the model
## Running nurse model (Update): bay_anx_threats_nur_str
## The desired updates require recompiling the model
## Running nurse model (Update): bay_anx_threats_nur_adj
## The desired updates require recompiling the model
## Running doctor model: bay_anx_viol_doc_cr
## Running doctor model: bay_anx_viol_doc_str
## Running doctor model: bay_anx_viol_doc_adj
## Running nurse model (Update): bay_anx_viol_nur_cr
## The desired updates require recompiling the model
## Running nurse model (Update): bay_anx_viol_nur_str
## The desired updates require recompiling the model
## Running nurse model (Update): bay_anx_viol_nur_adj
## The desired updates require recompiling the model
## Running doctor model: bay_anx_mean_doc_cr
## Running doctor model: bay_anx_mean_doc_str
## Running doctor model: bay_anx_mean_doc_adj
## Running nurse model (Update): bay_anx_mean_nur_cr
## The desired updates require recompiling the model
## Running nurse model (Update): bay_anx_mean_nur_str
## The desired updates require recompiling the model
## Running nurse model (Update): bay_anx_mean_nur_adj
## The desired updates require recompiling the model
## Running doctor model: bay_anx_purp_doc_cr
## Running doctor model: bay_anx_purp_doc_str
## Running doctor model: bay_anx_purp_doc_adj
## Running nurse model (Update): bay_anx_purp_nur_cr
## The desired updates require recompiling the model
## Running nurse model (Update): bay_anx_purp_nur_str
## The desired updates require recompiling the model
## Running nurse model (Update): bay_anx_purp_nur_adj
## The desired updates require recompiling the model
## Running doctor model: bay_suic_cols_doc_cr
## Running doctor model: bay_suic_cols_doc_str
## Running doctor model: bay_suic_cols_doc_adj
## Running nurse model (Update): bay_suic_cols_nur_cr
## The desired updates require recompiling the model
## Running nurse model (Update): bay_suic_cols_nur_str
## The desired updates require recompiling the model
## Running nurse model (Update): bay_suic_cols_nur_adj
## The desired updates require recompiling the model
## Running doctor model: bay_suic_sup_doc_cr
## Running doctor model: bay_suic_sup_doc_str
## Running doctor model: bay_suic_sup_doc_adj
## Running nurse model (Update): bay_suic_sup_nur_cr
## The desired updates require recompiling the model
## Running nurse model (Update): bay_suic_sup_nur_str
## The desired updates require recompiling the model
## Running nurse model (Update): bay_suic_sup_nur_adj
## The desired updates require recompiling the model
## Running doctor model: bay_suic_har_doc_cr
## Running doctor model: bay_suic_har_doc_str
## Running doctor model: bay_suic_har_doc_adj
## Running nurse model (Update): bay_suic_har_nur_cr
## The desired updates require recompiling the model
## Running nurse model (Update): bay_suic_har_nur_str
## The desired updates require recompiling the model
## Running nurse model (Update): bay_suic_har_nur_adj
## The desired updates require recompiling the model
## Running doctor model: bay_suic_bul_doc_cr
## Running doctor model: bay_suic_bul_doc_str
## Running doctor model: bay_suic_bul_doc_adj
## Running nurse model (Update): bay_suic_bul_nur_cr
## The desired updates require recompiling the model
## Running nurse model (Update): bay_suic_bul_nur_str
## The desired updates require recompiling the model
## Running nurse model (Update): bay_suic_bul_nur_adj
## The desired updates require recompiling the model
## Running doctor model: bay_suic_threats_doc_cr
## Running doctor model: bay_suic_threats_doc_str
## Running doctor model: bay_suic_threats_doc_adj
## Running nurse model (Update): bay_suic_threats_nur_cr
## The desired updates require recompiling the model
## Running nurse model (Update): bay_suic_threats_nur_str
## The desired updates require recompiling the model
## Running nurse model (Update): bay_suic_threats_nur_adj
## The desired updates require recompiling the model
## Running doctor model: bay_suic_viol_doc_cr
## Running doctor model: bay_suic_viol_doc_str
## Running doctor model: bay_suic_viol_doc_adj
## Running nurse model (Update): bay_suic_viol_nur_cr
## The desired updates require recompiling the model
## Running nurse model (Update): bay_suic_viol_nur_str
## The desired updates require recompiling the model
## Running nurse model (Update): bay_suic_viol_nur_adj
## The desired updates require recompiling the model
## Running doctor model: bay_suic_mean_doc_cr
## Running doctor model: bay_suic_mean_doc_str
## Running doctor model: bay_suic_mean_doc_adj
## Running nurse model (Update): bay_suic_mean_nur_cr
## The desired updates require recompiling the model
## Running nurse model (Update): bay_suic_mean_nur_str
## The desired updates require recompiling the model
## Running nurse model (Update): bay_suic_mean_nur_adj
## The desired updates require recompiling the model
## Running doctor model: bay_suic_purp_doc_cr
## Running doctor model: bay_suic_purp_doc_str
## Running doctor model: bay_suic_purp_doc_adj
## Running nurse model (Update): bay_suic_purp_nur_cr
## The desired updates require recompiling the model
## Running nurse model (Update): bay_suic_purp_nur_str
## The desired updates require recompiling the model
## Running nurse model (Update): bay_suic_purp_nur_adj
## The desired updates require recompiling the model

Table of results: Bayesian approach

brm_model_names <- ls(pattern = "^bay_", envir = .GlobalEnv)


brm_results_df <- 
  map_dfr(brm_model_names, function(obj_name) {
  
  model <- get(obj_name, envir = .GlobalEnv)
  
  # decode name
  parts <- str_split(obj_name, "_")[[1]]
  
  out_code <- parts[2]
  exp_code <- parts[3]
  prof_code <- parts[4]
  type_code <- parts[5]
  
  # decode elements
  outcome_label <- case_when(
    out_code == "dep"  ~ "Depression",
    out_code == "anx"  ~ "Anxiety",
    out_code == "suic" ~ "Suicide thoughts"
  )
  
  exposure_label <- case_when(
    exp_code == "cols"    ~ "Colleague support",
    exp_code == "sup"     ~ "Support from superiors",
    exp_code == "har"     ~ "Harassment",
    exp_code == "bul"     ~ "Bullying",
    exp_code == "threats" ~ "Violent threats",
    exp_code == "viol"    ~ "Physical violence",
    exp_code == "mean"    ~ "Meaning in work",
    exp_code == "purp"    ~ "Purpose in work",
    TRUE ~ exp_code
  )
  
  profession_label <- ifelse(prof_code == "doc",
                             "Doctor",
                             "Nurse")
  
  
  term_lookup <- case_when(
    exp_code == "cols"    ~ "work_21_dicYes",
    exp_code == "sup"     ~ "work_22_dicYes",
    exp_code == "har"     ~ "work_30_dicYes",
    exp_code == "bul"     ~ "work_33_dicYes",
    exp_code == "threats" ~ "work_31_dicYes",
    exp_code == "viol"    ~ "work_32_dicYes",
    exp_code == "mean"    ~ "wb_wami_1_dicYes",
    exp_code == "purp"    ~ "wb_wami_2_dicYes"
  )
  
  
  raw_col_name <- case_when(
    exp_code == "cols"    ~ "work_21_dic",
    exp_code == "sup"     ~ "work_22_dic",
    exp_code == "har"     ~ "work_30_dic",
    exp_code == "bul"     ~ "work_33_dic",
    exp_code == "threats" ~ "work_31_dic",
    exp_code == "viol"    ~ "work_32_dic",
    exp_code == "mean"    ~ "wb_wami_1_dic",
    exp_code == "purp"    ~ "wb_wami_2_dic"
  )
  
  
  model_label <- case_when(
    type_code == "cr" ~ "Crude",
    type_code == "str" ~ "Partially adjusted",
    type_code == "adj" ~ "Fully adjusted"
  )
  
  is_poisson <- model$family$family %in% c("poisson", "binomial")
  
  res <- tidy(
    model,
    effects = "fixed",
    conf.int = TRUE,
    conf.level = 0.95,
    exponentiate = is_poisson
  )
  
  target_row <- 
    res |>
    filter(term == term_lookup)
  
  if(nrow(target_row) > 0) {
    est  <- target_row$estimate[1]
    low  <- target_row$conf.low[1]
    high <- target_row$conf.high[1]
    
    
    
    dat <- model$data
    
    # Check if we can find the columns
    # We look for the raw_col_name we defined above
    if (raw_col_name %in% names(dat)) {
      
      # Extract vectors
      x_raw <- (dat[[raw_col_name]])
      # The response is usually the first column in brms data
      y_vec <- as.numeric(dat[[1]]) 
      
      if (is.factor(x_raw)) {
         x_vec <- as.numeric(x_raw) - 1  # Converts 1/2 to 0/1
      } else {
         x_vec <- as.numeric(as.character(x_raw)) # "Safe" cast
      }
      
      # Double check
      if (min(x_vec, na.rm = TRUE) == 1 && max(x_vec, na.rm = TRUE) == 2) {
          x_vec <- x_vec - 1
      }
      
      if (is_poisson) {
        # Normalize y to 0/1 if it was imported as 1/2
        if(max(y_vec, na.rm=TRUE) > 1) y_vec <- y_vec - 1
        
        # Calculate Observed Percentages
        # Note: We check for "No" and "Yes" explicitly. 
        # If data is 0/1, change to "0" and "1"
        risk_unexp_val <- mean(y_vec[x_vec == 0], na.rm = TRUE)
        risk_exp_val   <- mean(y_vec[x_vec == 1], na.rm = TRUE)
        
        abs_risk_unexposed <- sprintf("%.1f%%", risk_unexp_val * 100)
        abs_risk_exposed   <- sprintf("%.1f%%", risk_exp_val * 100)
        
      } else {
        # Linear Mean
        mean_unexp_val <- mean(y_vec[x_vec == 0], na.rm = TRUE)
        mean_exp_val   <- mean(y_vec[x_vec == 1], na.rm = TRUE)
        
        abs_risk_unexposed <- sprintf("%.2f", mean_unexp_val)
        abs_risk_exposed   <- sprintf("%.2f", mean_exp_val)
      }
    } else {
      # Debugging: if it still fails, print what columns are actually there
      # warning(paste("Could not find column:", raw_col_name))
      abs_risk_unexposed <- NA
      abs_risk_exposed   <- NA
    }
    
    
    tibble(
      Outcome = outcome_label,
      Exposure = exposure_label,
      Profession = profession_label,
      Model = model_label,
      Type = ifelse(is_poisson, "PR", "Beta"),
      Est_CI = sprintf("%.2f (%.2f, %.2f)", est, low, high),
      # ADDED: Include the calculated columns here
      Risk_Unexposed = abs_risk_unexposed,
      Risk_Exposed = abs_risk_exposed,
      Rhat = max(rhat(model), na.rm = TRUE)
    )
  } else {
    
    return(NULL)
  
    }
  })

brm_results_df
## # A tibble: 144 × 9
##    Outcome Exposure    Profession Model Type  Est_CI Risk_Unexposed Risk_Exposed
##    <chr>   <chr>       <chr>      <chr> <chr> <chr>  <chr>          <chr>       
##  1 Anxiety Bullying    Doctor     Full… PR    2.09 … 18.3%          42.3%       
##  2 Anxiety Bullying    Doctor     Crude PR    2.31 … 18.2%          42.4%       
##  3 Anxiety Bullying    Doctor     Part… PR    2.08 … 18.2%          42.3%       
##  4 Anxiety Bullying    Nurse      Full… PR    2.64 … 12.5%          35.1%       
##  5 Anxiety Bullying    Nurse      Crude PR    2.74 … 12.5%          34.9%       
##  6 Anxiety Bullying    Nurse      Part… PR    2.63 … 12.4%          34.9%       
##  7 Anxiety Colleague … Doctor     Full… PR    0.65 … 32.0%          19.9%       
##  8 Anxiety Colleague … Doctor     Crude PR    0.63 … 32.0%          19.9%       
##  9 Anxiety Colleague … Doctor     Part… PR    0.65 … 31.9%          19.9%       
## 10 Anxiety Colleague … Nurse      Full… PR    0.58 … 22.2%          12.6%       
## # ℹ 134 more rows
## # ℹ 1 more variable: Rhat <dbl>
# Save
saveRDS(brm_results_df, "out/dataframes/brm_results.rds")
writexl::write_xlsx(brm_results_df, "out/dataframes/brm_results.xlsx")

brm_results_df <- 
  readRDS("out/dataframes/brm_results.rds") |> 
  mutate(Exposure = ifelse(Exposure == "Harassment",
                           "Sexual Harassment", # Naming check
                           Exposure))

# Build table with function
tbl_bay_res <- 
  build_bay_gt(brm_results_df, "PR", 
               "**Bayesian Models**", 
               "Posterior Median PR (95% CrI). Models specified with weakly informative priors: These represent prior beliefs of the estimates. Using them gives more flexibility for the data. All models include Region as a second order covariate.")


tbl_bay_res
Bayesian Models
Doctor
Nurse
Crude1 Partially adjusted2 Fully adjusted3 Crude1 Partially adjusted2 Fully adjusted3
Depression
Bullying 2.21 (2.06, 2.37) 2.01 (1.87, 2.17) 2.02 (1.87, 2.17) 2.63 (2.42, 2.86) 2.48 (2.29, 2.69) 2.48 (2.28, 2.69)
Sexual Harassment 1.77 (1.61, 1.95) 1.48 (1.34, 1.63) 1.48 (1.34, 1.65) 2.35 (2.11, 2.61) 2.06 (1.83, 2.30) 2.06 (1.84, 2.31)
Violent threats 1.99 (1.83, 2.15) 1.83 (1.70, 1.98) 1.84 (1.70, 1.99) 2.26 (2.05, 2.48) 2.10 (1.90, 2.32) 2.11 (1.91, 2.32)
Physical violence 1.66 (1.41, 1.93) 1.47 (1.24, 1.72) 1.48 (1.25, 1.73) 2.19 (1.88, 2.53) 1.99 (1.70, 2.32) 1.99 (1.69, 2.33)
Colleague support 0.63 (0.59, 0.68) 0.66 (0.62, 0.71) 0.66 (0.61, 0.71) 0.58 (0.54, 0.63) 0.60 (0.55, 0.65) 0.60 (0.55, 0.65)
Support from superiors 0.58 (0.54, 0.63) 0.62 (0.57, 0.67) 0.62 (0.57, 0.67) 0.50 (0.46, 0.54) 0.52 (0.48, 0.56) 0.52 (0.48, 0.56)
Meaning in work 0.48 (0.44, 0.53) 0.50 (0.46, 0.55) 0.50 (0.46, 0.55) 0.42 (0.38, 0.46) 0.44 (0.40, 0.48) 0.44 (0.40, 0.48)
Purpose in work 0.46 (0.41, 0.50) 0.48 (0.44, 0.53) 0.48 (0.44, 0.54) 0.46 (0.42, 0.52) 0.49 (0.44, 0.54) 0.49 (0.44, 0.55)
Anxiety
Bullying 2.31 (2.12, 2.51) 2.08 (1.91, 2.27) 2.09 (1.91, 2.28) 2.74 (2.50, 3.01) 2.63 (2.39, 2.89) 2.64 (2.40, 2.92)
Sexual Harassment 1.95 (1.74, 2.18) 1.60 (1.42, 1.80) 1.61 (1.42, 1.81) 2.49 (2.20, 2.80) 2.24 (1.96, 2.56) 2.25 (1.97, 2.57)
Violent threats 2.05 (1.87, 2.24) 1.90 (1.74, 2.09) 1.92 (1.75, 2.11) 2.32 (2.08, 2.57) 2.22 (1.98, 2.49) 2.25 (1.99, 2.52)
Physical violence 1.91 (1.58, 2.27) 1.70 (1.41, 2.03) 1.75 (1.46, 2.09) 2.18 (1.83, 2.57) 2.06 (1.72, 2.46) 2.08 (1.75, 2.46)
Colleague support 0.63 (0.57, 0.68) 0.65 (0.60, 0.71) 0.65 (0.60, 0.71) 0.57 (0.52, 0.63) 0.58 (0.53, 0.64) 0.58 (0.53, 0.63)
Support from superiors 0.57 (0.52, 0.62) 0.60 (0.55, 0.65) 0.60 (0.54, 0.65) 0.50 (0.45, 0.55) 0.52 (0.47, 0.57) 0.52 (0.47, 0.57)
Meaning in work 0.48 (0.43, 0.53) 0.50 (0.45, 0.56) 0.50 (0.45, 0.56) 0.46 (0.41, 0.52) 0.47 (0.42, 0.53) 0.47 (0.42, 0.53)
Purpose in work 0.44 (0.39, 0.50) 0.47 (0.42, 0.53) 0.47 (0.42, 0.53) 0.49 (0.44, 0.56) 0.51 (0.45, 0.58) 0.51 (0.45, 0.59)
Suicide thoughts
Bullying 2.45 (2.18, 2.76) 2.20 (1.95, 2.47) 2.20 (1.94, 2.48) 3.30 (2.90, 3.78) 3.08 (2.70, 3.53) 3.05 (2.69, 3.46)
Sexual Harassment 2.55 (2.20, 2.94) 2.11 (1.82, 2.45) 2.10 (1.81, 2.45) 3.21 (2.71, 3.77) 2.75 (2.33, 3.26) 2.72 (2.30, 3.21)
Violent threats 2.45 (2.16, 2.76) 2.15 (1.90, 2.44) 2.16 (1.90, 2.44) 2.80 (2.42, 3.21) 2.54 (2.19, 2.95) 2.52 (2.16, 2.92)
Physical violence 2.71 (2.19, 3.31) 2.25 (1.82, 2.77) 2.26 (1.81, 2.79) 2.94 (2.35, 3.67) 2.57 (2.06, 3.20) 2.56 (2.05, 3.19)
Colleague support 0.61 (0.54, 0.68) 0.64 (0.57, 0.72) 0.64 (0.57, 0.72) 0.52 (0.45, 0.59) 0.53 (0.46, 0.61) 0.53 (0.46, 0.60)
Support from superiors 0.57 (0.50, 0.64) 0.61 (0.54, 0.69) 0.61 (0.54, 0.69) 0.54 (0.47, 0.62) 0.56 (0.49, 0.64) 0.56 (0.49, 0.63)
Meaning in work 0.41 (0.36, 0.47) 0.44 (0.38, 0.51) 0.45 (0.38, 0.52) 0.46 (0.39, 0.53) 0.48 (0.41, 0.56) 0.48 (0.41, 0.56)
Purpose in work 0.36 (0.31, 0.42) 0.39 (0.34, 0.47) 0.40 (0.34, 0.47) 0.43 (0.36, 0.51) 0.45 (0.38, 0.54) 0.45 (0.38, 0.54)
Posterior Median PR (95% CrI). Models specified with weakly informative priors: These represent prior beliefs of the estimates. Using them gives more flexibility for the data. All models include Region as a second order covariate.
1 Region as second-order covariate only.
2 Adjusted by Gender, Age group and Proximity to combat areas and occupied territories .
3 Partially adjusted models plus specific covariates: Bullying and sexual harassment adjusted by Healthcare setting, Post-graduate training and Length of service. Violent threats and physical violence adjusted by Healthcare setting. Support from colleagues or superiors adjusted by Healthcare setting and Length of service. Finding meaning or purpose in job adjusted by Healthcare setting, Relationship status, Having children, and Length of service.
gtsave(tbl_bay_res, "out/tables/bay_res_tbl.docx")


ls() |> 
  str_subset("^bay_") |> 
  rm(list = _)

rm(brms_tasks, bin_priors, brm_model_names, run_brms_pair, build_bay_gt)

Sensitivity analyses: Restrictive priors

Restrictive priors

# for sensitivity analyses, there is a previous article with GAD-7 and PHQ-9 
# prevalences on physicians: https://doi.org/10.1016/j.psychres.2024.115836

phq_doc_p <- 0.108
intercept_prior_phq <- log(phq_doc_p)

priors_res_phq_doc <- c(
  # informative intercept based on the article, small SD (0.5)
  prior_string(glue("normal({intercept_prior_phq}, 0.5)"), 
               class = "Intercept"),
  
  # restrictive predictors (no PR known)
  # force conservative model, with sd of 0.25, forces data to prove effect
  prior(normal(0, 0.25), class = b),
  
  # weak random effect (standard practice)
  prior(student_t(3, 0, 1), class = sd)
)

gad_doc_p <- 0.165
intercept_prior_gad <- log(gad_doc_p)

priors_res_gad_doc <- c(
  # informative intercept based on the article
  prior_string(glue("normal({intercept_prior_gad}, 0.5)"), 
               class = "Intercept"),
  
  # restrictive predictors (no PR known)
  # force model to be conservative
  prior(normal(0, 0.25), class = b),
  
  # weak random effect (standard practice)
  prior(student_t(3, 0, 1), class = sd)
)
  

# for nursing we do not have information, sorestrict with skeptical betas
# (Vague but mathematically valid for Log-Link)
# Centered on ~13% prevalence, but wide enough to cover 0% to ~50%
priors_sens_nur <- c(
  prior(normal(-2, 1.5), class = Intercept),
  
  # same skepticism to exposure effects
  prior(normal(0, 0.25), class = b),
  
  prior(student_t(3, 0, 1), class = sd)
) 

Models with restrictive priors

# define only phq and gad, is the information we have available
sens_tasks <- expand_grid(
  outcome = c("phq_co", "gad_co"), # restrict here
  exposure = names(exposure_map)
)

# Run
pwalk(
  list(sens_tasks$outcome, sens_tasks$exposure),
  function(out, exp) {
    
    message(glue("\nRunning Sensitivity Analysis for: {out} + {exp}"))
    run_brms_sensitivity(
      outcome = out, 
      exposure = exp, 
      design_df = ds_ua,
      output_dir = "out/bayesian_models_sens" # Saves in new folder
    )
  }
)
## Running Sensitivity Analysis for: phq_co + work_21_dic
## >> Doc Prior: PHQ Informative (Log-Odds: -2.23)
## >> Nur Prior: Weak Intercept + Skeptical Beta
## Running Sensitivity Analysis for: phq_co + work_22_dic
## >> Doc Prior: PHQ Informative (Log-Odds: -2.23)
## >> Nur Prior: Weak Intercept + Skeptical Beta
## Running Sensitivity Analysis for: phq_co + work_30_dic
## >> Doc Prior: PHQ Informative (Log-Odds: -2.23)
## >> Nur Prior: Weak Intercept + Skeptical Beta
## Running Sensitivity Analysis for: phq_co + work_33_dic
## >> Doc Prior: PHQ Informative (Log-Odds: -2.23)
## >> Nur Prior: Weak Intercept + Skeptical Beta
## Running Sensitivity Analysis for: phq_co + work_31_dic
## >> Doc Prior: PHQ Informative (Log-Odds: -2.23)
## >> Nur Prior: Weak Intercept + Skeptical Beta
## Running Sensitivity Analysis for: phq_co + work_32_dic
## >> Doc Prior: PHQ Informative (Log-Odds: -2.23)
## >> Nur Prior: Weak Intercept + Skeptical Beta
## Running Sensitivity Analysis for: phq_co + wb_wami_1_dic
## >> Doc Prior: PHQ Informative (Log-Odds: -2.23)
## >> Nur Prior: Weak Intercept + Skeptical Beta
## Running Sensitivity Analysis for: phq_co + wb_wami_2_dic
## >> Doc Prior: PHQ Informative (Log-Odds: -2.23)
## >> Nur Prior: Weak Intercept + Skeptical Beta
## Running Sensitivity Analysis for: gad_co + work_21_dic
## >> Doc Prior: GAD Informative (Log-Odds: -1.8)
## >> Nur Prior: Weak Intercept + Skeptical Beta
## Running Sensitivity Analysis for: gad_co + work_22_dic
## >> Doc Prior: GAD Informative (Log-Odds: -1.8)
## >> Nur Prior: Weak Intercept + Skeptical Beta
## Running Sensitivity Analysis for: gad_co + work_30_dic
## >> Doc Prior: GAD Informative (Log-Odds: -1.8)
## >> Nur Prior: Weak Intercept + Skeptical Beta
## Running Sensitivity Analysis for: gad_co + work_33_dic
## >> Doc Prior: GAD Informative (Log-Odds: -1.8)
## >> Nur Prior: Weak Intercept + Skeptical Beta
## Running Sensitivity Analysis for: gad_co + work_31_dic
## >> Doc Prior: GAD Informative (Log-Odds: -1.8)
## >> Nur Prior: Weak Intercept + Skeptical Beta
## Running Sensitivity Analysis for: gad_co + work_32_dic
## >> Doc Prior: GAD Informative (Log-Odds: -1.8)
## >> Nur Prior: Weak Intercept + Skeptical Beta
## Running Sensitivity Analysis for: gad_co + wb_wami_1_dic
## >> Doc Prior: GAD Informative (Log-Odds: -1.8)
## >> Nur Prior: Weak Intercept + Skeptical Beta
## Running Sensitivity Analysis for: gad_co + wb_wami_2_dic
## >> Doc Prior: GAD Informative (Log-Odds: -1.8)
## >> Nur Prior: Weak Intercept + Skeptical Beta
# get files
sens_files <- list.files("out/bayesian_models_sens", 
                         full.names = TRUE)

# extract data
bay_sens_res_df <- map_dfr(sens_files, 
                           function(file_path) {
  
  # parse filename to get metadata
  fname <- str_remove(basename(file_path), ".rds")
  parts <- str_split(fname, "_")[[1]]
  
  # parts[1] = "bay", parts[2] = "sens"
  out_code  <- parts[3]
  exp_code  <- parts[4]
  prof_code <- parts[5]
  type_code <- parts[6] # cr, str, or adj
  
  # We only care about Fully Adjusted for the table
  if (type_code != "adj") return(NULL)
  
  # Decode Labels (Same as before)
  outcome_label <- case_when(
    out_code == "dep" ~ "Depression",
    out_code == "anx" ~ "Anxiety"
  )
  
  exposure_label <- case_when(
    exp_code == "cols"    ~ "Colleague support",
    exp_code == "sup"     ~ "Support from superiors",
    exp_code == "har"     ~ "Sexual Harassment",
    exp_code == "bul"     ~ "Bullying",
    exp_code == "threats" ~ "Violent threats",
    exp_code == "viol"    ~ "Physical violence",
    exp_code == "mean"    ~ "Meaning in work",
    exp_code == "purp"    ~ "Purpose in work"
  )
  
  profession_label <- ifelse(prof_code == "doc", "Doctor", "Nurse")
  
  # Determine Exposure Term
  term_lookup <- case_when(
    exp_code == "cols"    ~ "work_21_dicYes",
    exp_code == "sup"     ~ "work_22_dicYes",
    exp_code == "har"     ~ "work_30_dicYes",
    exp_code == "bul"     ~ "work_33_dicYes",
    exp_code == "threats" ~ "work_31_dicYes",
    exp_code == "viol"    ~ "work_32_dicYes",
    exp_code == "mean"    ~ "wb_wami_1_dicYes",
    exp_code == "purp"    ~ "wb_wami_2_dicYes"
  )
  
  # Load Model
  model <- readRDS(file_path)
  
  # Tidy
  res <- tidy(
    model, 
    effects = "fixed", 
    conf.int = TRUE, 
    conf.level = 0.95, 
    exponentiate = TRUE
    )
  
  target <- res |> filter(term == term_lookup)
  
  if(nrow(target) > 0) {
    est <- target$estimate[1]
    low <- target$conf.low[1]
    high <- target$conf.high[1]
    
    tibble(
      Outcome = outcome_label,
      Exposure = exposure_label,
      Profession = profession_label,
      Analysis = "Sensitivity (Restrictive)", # Mark this row
      Est_CI = sprintf("%.2f (%.2f, %.2f)", est, low, high)
    )
  } else {
    NULL
  }
})

bay_sens_res_df
## # A tibble: 32 × 5
##    Outcome Exposure          Profession Analysis                  Est_CI        
##    <chr>   <chr>             <chr>      <chr>                     <chr>         
##  1 Anxiety Bullying          Doctor     Sensitivity (Restrictive) 2.06 (1.89, 2…
##  2 Anxiety Bullying          Nurse      Sensitivity (Restrictive) 2.58 (2.34, 2…
##  3 Anxiety Colleague support Doctor     Sensitivity (Restrictive) 0.66 (0.61, 0…
##  4 Anxiety Colleague support Nurse      Sensitivity (Restrictive) 0.58 (0.53, 0…
##  5 Anxiety Sexual Harassment Doctor     Sensitivity (Restrictive) 1.59 (1.42, 1…
##  6 Anxiety Sexual Harassment Nurse      Sensitivity (Restrictive) 2.18 (1.91, 2…
##  7 Anxiety Meaning in work   Doctor     Sensitivity (Restrictive) 0.51 (0.46, 0…
##  8 Anxiety Meaning in work   Nurse      Sensitivity (Restrictive) 0.49 (0.44, 0…
##  9 Anxiety Purpose in work   Doctor     Sensitivity (Restrictive) 0.49 (0.43, 0…
## 10 Anxiety Purpose in work   Nurse      Sensitivity (Restrictive) 0.53 (0.47, 0…
## # ℹ 22 more rows
# Save
writexl::write_xlsx(bay_sens_res_df, "out/dataframes/bay_restr_res.xlsx")
saveRDS(bay_sens_res_df, "out/dataframes/bay_res_sens.rds")
bay_results_df <- 
  readRDS("out/dataframes/brm_results.rds") |> 
  mutate(Exposure = case_when(
    Exposure == "Harassment" ~ "Sexual Harassment",
    TRUE ~ Exposure
  ))

# Prepare results, filter full models
main_subset <- 
  
  bay_results_df |>
  filter(Model == "Fully adjusted") |>
  # outcomes studied for sensitivity
  filter(Outcome %in% c("Depression", "Anxiety")) |>
  select(Outcome, Exposure, Profession, Est_CI) |>
  mutate(Analysis = "Main (Weak Priors)")


# load sensitivity df
bay_res_sens_df <- readRDS("out/dataframes/bay_res_sens.rds")


# prepare ds
sens_subset <- 
  
  bay_res_sens_df |>
  select(Outcome, Exposure, Profession, Est_CI, Analysis)

# Merge
bay_comparison_df <- 
  
  bind_rows(main_subset, sens_subset) |> 
  mutate(
    # Extract numbers
    PR = as.numeric(str_extract(Est_CI, "^[0-9\\.]+")),
    Lower = as.numeric(str_extract(Est_CI, "(?<=\\()[0-9\\.]+")),
    Upper = as.numeric(str_extract(Est_CI, "[0-9\\.]+(?=\\))")),
    
    # FIX ORDER: Convert to factor. 
    # We use rev() so "Bullying" appears at the TOP of the plot
    
    Exposure = factor(Exposure, levels = rev(exposure_order))
  )


# table

tbl_sensitivity <- 
  
  bay_comparison_df |>
  select(Outcome, Exposure, Profession, Analysis, Est_CI) |> 
  # Pivot to wide format
  pivot_wider(
    names_from = c(Profession, Analysis),
    values_from = Est_CI,
    names_sep = "_"
  ) |>
  # Order columns logically
  select(Outcome, Exposure, 
         `Doctor_Main (Weak Priors)`, `Doctor_Sensitivity (Restrictive)`,
         `Nurse_Main (Weak Priors)`, `Nurse_Sensitivity (Restrictive)`) |>
  mutate(Outcome = factor(Outcome, levels = c("Depression", "Anxiety")),
         Exposure = factor(Exposure, levels = exposure_order) 
         )|>
  arrange(Outcome, Exposure) |> 
  # Create Table
  gt(
    groupname_col = "Outcome", 
    rowname_col = "Exposure"
    ) |>
  
  # Headers
  tab_header(
    title = md("**Sensitivity Analysis: Restrictive Priors**"),
    subtitle = "Fully Adjusted Prevalence Ratios (95% CrI)"
  ) |>
  
  # Spanners for Profession
  tab_spanner(
    label = md("**Doctor**"),
    columns = starts_with("Doctor")
  ) |>
  tab_spanner(
    label = md("**Nurse**"),
    columns = starts_with("Nurse")
  ) |>
  
  # Clean Column Labels (Remove the "Doctor_" prefix)
  cols_label(
    `Doctor_Main (Weak Priors)` = "Weakly Informative Priors",
    `Doctor_Sensitivity (Restrictive)` = "Restrictive Priors",
    `Nurse_Main (Weak Priors)` = "Weakly Informative Priors",
    `Nurse_Sensitivity (Restrictive)` = "Restrictive Priors"
  ) |>
  
  # Formatting
  cols_align(align = "center", columns = contains("_")) |>
  tab_stub_indent(rows = everything(), indent = 3) |>
  tab_footnote(
    footnote = paste0( "Main Analysis: Weak priors (Normal(-1.5,1)). Restrictive: Doctors use informative intercepts based on prevalence + Skeptical Betas (Normal(0, 0.25)). Nurses use Skeptical Betas. All models include Region as a second-order covariate. Adjusted by Age group, Gender and Proximity to combat areas and occupied territories plus specific covariates:", "\n",
                 "Bullying and sexual harassment adjusted by Healthcare setting, Post-graduate training and Length of service.", "\n",
                 "Violent threats and physical violence adjusted by Healthcare setting.", "\n",
                 "Support from colleagues or superiors adjusted by Healthcare setting and Length of service.", "\n",
                 "Finding meaning or purpose in job adjusted by Healthcare setting, Relationship status, Having children, and Length of service."
  ))

# Save
gtsave(tbl_sensitivity, "out/tables/bayes_sensitivity_comparison.docx")

tbl_sensitivity
Sensitivity Analysis: Restrictive Priors
Fully Adjusted Prevalence Ratios (95% CrI)
Doctor
Nurse
Weakly Informative Priors Restrictive Priors Weakly Informative Priors Restrictive Priors
Depression
Bullying 2.02 (1.87, 2.17) 2.00 (1.86, 2.15) 2.48 (2.28, 2.69) 2.44 (2.26, 2.65)
Sexual Harassment 1.48 (1.34, 1.65) 1.47 (1.33, 1.63) 2.06 (1.84, 2.31) 2.03 (1.81, 2.27)
Violent threats 1.84 (1.70, 1.99) 1.83 (1.69, 1.97) 2.11 (1.91, 2.32) 2.07 (1.88, 2.29)
Physical violence 1.48 (1.25, 1.73) 1.44 (1.23, 1.67) 1.99 (1.69, 2.33) 1.91 (1.65, 2.21)
Colleague support 0.66 (0.61, 0.71) 0.66 (0.62, 0.71) 0.60 (0.55, 0.65) 0.60 (0.56, 0.65)
Support from superiors 0.62 (0.57, 0.67) 0.62 (0.58, 0.67) 0.52 (0.48, 0.56) 0.52 (0.48, 0.57)
Meaning in work 0.50 (0.46, 0.55) 0.51 (0.47, 0.56) 0.44 (0.40, 0.48) 0.45 (0.41, 0.49)
Purpose in work 0.48 (0.44, 0.54) 0.49 (0.45, 0.55) 0.49 (0.44, 0.55) 0.50 (0.45, 0.56)
Anxiety
Bullying 2.09 (1.91, 2.28) 2.06 (1.89, 2.25) 2.64 (2.40, 2.92) 2.58 (2.34, 2.84)
Sexual Harassment 1.61 (1.42, 1.81) 1.59 (1.42, 1.78) 2.25 (1.97, 2.57) 2.18 (1.91, 2.48)
Violent threats 1.92 (1.75, 2.11) 1.89 (1.72, 2.08) 2.25 (1.99, 2.52) 2.19 (1.96, 2.43)
Physical violence 1.75 (1.46, 2.09) 1.67 (1.39, 1.98) 2.08 (1.75, 2.46) 1.96 (1.65, 2.32)
Colleague support 0.65 (0.60, 0.71) 0.66 (0.61, 0.72) 0.58 (0.53, 0.63) 0.58 (0.53, 0.64)
Support from superiors 0.60 (0.54, 0.65) 0.60 (0.55, 0.65) 0.52 (0.47, 0.57) 0.52 (0.48, 0.57)
Meaning in work 0.50 (0.45, 0.56) 0.51 (0.46, 0.57) 0.47 (0.42, 0.53) 0.49 (0.44, 0.54)
Purpose in work 0.47 (0.42, 0.53) 0.49 (0.43, 0.55) 0.51 (0.45, 0.59) 0.53 (0.47, 0.60)
Main Analysis: Weak priors (Normal(-1.5,1)). Restrictive: Doctors use informative intercepts based on prevalence + Skeptical Betas (Normal(0, 0.25)). Nurses use Skeptical Betas. All models include Region as a second-order covariate. Adjusted by Age group, Gender and Proximity to combat areas and occupied territories plus specific covariates: Bullying and sexual harassment adjusted by Healthcare setting, Post-graduate training and Length of service. Violent threats and physical violence adjusted by Healthcare setting. Support from colleagues or superiors adjusted by Healthcare setting and Length of service. Finding meaning or purpose in job adjusted by Healthcare setting, Relationship status, Having children, and Length of service.
#plot

# Create a clean plot
forest_bayes_comp <- 
  
  bay_comparison_df |>
  # extract numeric estimates for plotting
  mutate(
    PR = as.numeric(str_extract(Est_CI, "^[0-9\\.]+")),
    Lower = as.numeric(str_extract(Est_CI, "(?<=\\()[0-9\\.]+")),
    Upper = as.numeric(str_extract(Est_CI, "[0-9\\.]+(?=\\))"))
  ) |>
  mutate(Outcome = factor(Outcome, levels = c("Depression", "Anxiety"))) |> 
  ggplot(aes(x = PR, y = Exposure, shape = Analysis)) +
  geom_point(position = position_dodge(width = 0.5), size = 3) +
  geom_errorbar(aes(xmin = Lower, xmax = Upper), 
                 position = position_dodge(width = 0.5)) +
  facet_wrap(~Profession + Outcome, scales = "free_y") +
  geom_vline(xintercept = 1, linetype = "dashed") +
  scale_x_log10(breaks = c(0.2, 0.5, 1, 2, 4),
                labels = scales::label_number(
                  accuracy = 0.1,
                  decimal.mark = "·"
                )) +
  ggpubr::theme_pubr() + 
  theme(
    legend.text = element_text(size = 10),
    axis.text.x = element_text(size = 10),
    axis.title.x = element_text(size = 10),
    axis.text.y = element_text(size = 10),
    axis.title.y = element_text(size = 10),
    strip.text = element_text(size = 10)
  )

forest_bayes_comp

ggsave(filename = "forest_bayes_comparison.pdf",
       plot = forest_bayes_comp,
       path = "out/plots/",
       width = 210,
       height = 170,
       units = "mm",
       dpi = 320,
       scale = 1.5
       )

Model diagnostics

# define file paths for each 
main_files <- list.files("out/bayesian_models",
                         full.names = TRUE,
                         pattern = "\\.rds$")

agg_files <- list.files("out/bayesian_models_agg",
                         full.names = TRUE,
                         pattern = "\\.rds$")

sens_files <- list.files("out/bayesian_models_sens",
                         full.names = TRUE,
                         pattern = "\\.rds$")


# execute
df_main_diag <- process_disk_models(main_files, 
                                    "Weakly Informative Priors")
df_agg_diag <- process_disk_models(agg_files, "Weakly Informative Priors")
df_sens_diag <- process_disk_models(sens_files, "Restrictive Priors")

# Combine and clean
final_diagnostics <- 
  
  bind_rows(df_main_diag, df_agg_diag, df_sens_diag) |> 
  mutate(clean_id = str_remove(model_id, "bay_")) |> 
  mutate(clean_id = str_remove(clean_id, "sens_")) |> 
  separate(
    clean_id,
    into = c("outcome", "exposure", "group", "adjustment"),
    sep = "_",
    extra = "merge"
  ) |> 
  mutate(
    outcome = case_match(outcome,
                         "dep" ~ "Depression",
                         "anx" ~ "Anxiety",
                         "suic" ~ "Suicide thoughts",
                         .default = outcome
                         ),
    exposure = case_match(exposure,
                          "bul" ~ "Bullying",
                          "har" ~ "Sexual Harassment",
                          "threats" ~ "Violent threats",
                          "viol" ~ "Physical violence",
                          "cols" ~ "Colleague support",
                          "sup" ~ "Support from superiors",
                          "mean" ~ "Meaning in work",
                          "purp" ~ "Purpose in work",
                          .default = exposure),
    group = case_match(group,
                       "agg" ~ "Aggregate",
                       "doc" ~ "Doctor",
                       "nur" ~ "Nurse",
                       .default = group),
    adjustment = case_match(adjustment,
                            "cr" ~ "Crude",
                            "str" ~ "Partially adjusted",
                            "adj" ~ "Fully adjusted",
                            .default = adjustment)
    ) |> 
  filter(outcome != "wb") |> 
  select(Type, outcome, exposure, group, adjustment, max_rhat, min_ess_bulk, 
         divergences)


final_diagnostics
## # A tibble: 248 × 8
##    Type      outcome exposure group adjustment max_rhat min_ess_bulk divergences
##    <chr>     <chr>   <chr>    <chr> <chr>         <dbl>        <dbl>       <int>
##  1 Weakly I… Anxiety Bullying Doct… Fully adj…     1.00        1112.           0
##  2 Weakly I… Anxiety Bullying Doct… Crude          1.00        1130.           0
##  3 Weakly I… Anxiety Bullying Doct… Partially…     1.00        1010.           0
##  4 Weakly I… Anxiety Bullying Nurse Fully adj…     1.00         800.           0
##  5 Weakly I… Anxiety Bullying Nurse Crude          1.00         901.           0
##  6 Weakly I… Anxiety Bullying Nurse Partially…     1.00         827.           0
##  7 Weakly I… Anxiety Colleag… Doct… Fully adj…     1.00        1009.           0
##  8 Weakly I… Anxiety Colleag… Doct… Crude          1.01        1060.           0
##  9 Weakly I… Anxiety Colleag… Doct… Partially…     1.01        1083.           0
## 10 Weakly I… Anxiety Colleag… Nurse Fully adj…     1.00        1060.           0
## # ℹ 238 more rows
# Save
saveRDS(final_diagnostics, "out/dataframes/bayes_diagnostics.rds")
writexl::write_xlsx(final_diagnostics, 
                    "out/dataframes/bayes_diagnostics.xlsx")
# load 4 models, 2 main and 2 sensitivity, same out x exp, both prof
bay_dep_bul_doc_adj <- 
  readRDS("out/bayes_diagnostic_mods/bay_dep_bul_doc_adj.rds")

bay_dep_bul_nur_adj <- 
  readRDS("out/bayes_diagnostic_mods/bay_dep_bul_nur_adj.rds")

bay_sens_dep_bul_doc_adj <- 
  readRDS("out/bayes_diagnostic_mods/bay_sens_dep_bul_doc_adj.rds")

bay_sens_dep_bul_nur_adj <- 
  readRDS("out/bayes_diagnostic_mods/bay_sens_dep_bul_nur_adj.rds")


# run pipeline
plots_main_doc <- 
  create_diag_plots(bay_dep_bul_doc_adj, 
                    "Doctors (Weakly Informative)",
                    "b_work_33_dicYes")
## No divergences to plot.
plots_main_nur <- 
  create_diag_plots(bay_dep_bul_nur_adj, 
                    "Nurses (Weakly Informative)", 
                    "b_work_33_dicYes")
## No divergences to plot.
plots_sens_doc <- 
  create_diag_plots(bay_sens_dep_bul_doc_adj, 
                    "Doctors (Restrictive)", 
                    "b_work_33_dicYes")
## No divergences to plot.
plots_sens_nur <- 
  create_diag_plots(bay_sens_dep_bul_nur_adj, 
                    "Nurses (Restrictive)",
                    "b_work_33_dicYes")
## No divergences to plot.
# grid
final_dx_plots_bayes <- (
  (plots_main_doc$trace + plots_main_doc$ppc) /
  (plots_main_nur$trace + plots_main_nur$ppc) /
  (plots_sens_doc$trace + plots_sens_doc$ppc) /
  (plots_sens_nur$trace + plots_sens_nur$ppc)
  ) + 
  plot_layout(heights = c(1, 1, 1, 1))

# View
final_dx_plots_bayes

ggsave(
  "bayes_diagnostic_plots.pdf",
  plot = final_dx_plots_bayes,
  path = "out/plots/",
  scale = 1.5,
  width = 220,
  height = 160,
  unit = "mm",
  dpi = 350
)

rm(bay_dep_bul_doc_adj, bay_dep_bul_nur_adj, bay_sens_dep_bul_doc_adj,
   bay_sens_dep_bul_nur_adj, final_dx_plots_bayes)
bayes_dx <- 
  readRDS("out/dataframes/bayes_diagnostics.rds") |> 
  mutate(exposure = if_else(exposure == "purp",
                           "Purpose in work",
                           exposure))

# edit datasets
data_main <- prepare_dx_table_data(bayes_dx, "Weakly Informative Priors")
data_sens <- prepare_dx_table_data(bayes_dx, "Restrictive Priors")


# create table

tbl_main_dx <-
  
  data_main |>
  mutate(outcome = factor(outcome, levels = outcome_order),
         adjustment = factor(adjustment, levels = adjustment_order),
         exposure = factor(exposure, levels = exposure_order)
         ) |>
  arrange(outcome, exposure, adjustment) |>
  # doing this the output in word will look ok
  group_by(outcome, exposure) |> 
  mutate(
    exposure_label = ifelse(row_number() == 1, as.character(exposure), "") 
  ) |> 
  ungroup() |> 
  gt(groupname_col = "outcome") |> 
  cols_move_to_start(columns = c(exposure_label, adjustment)) |> 
  tab_spanner(
    label = "Doctors",
    columns = starts_with("Doc")
    ) |>
  tab_spanner(
    label = "Nurses",
    columns = starts_with("Nur")
    ) |>
  tab_spanner(
    label = "Aggregate",
    columns = starts_with("Agg")
    ) |>
  cols_label(
    exposure_label = "",
    adjustment = "",
    Doctor_max_rhat = "Max R-hat",
    Doctor_min_ess_bulk = "Min ESS",
    Doctor_divergences = "Div.",
    Nurse_max_rhat = "Max R-hat",
    Nurse_min_ess_bulk = "Min ESS",
    Nurse_divergences = "Div.",
    Aggregate_max_rhat = "Max R-hat",
    Aggregate_min_ess_bulk = "Min ESS",
    Aggregate_divergences = "Div.",
    ) |>
  fmt_number(
    columns = ends_with("rhat"),
    decimals = 2
    ) |>
  fmt_integer(
    columns = ends_with("bulk")
    ) |>
  tab_header(
    title = "Bayes' Diagnostics for weakly informative priors"
    ) |>
  tab_options(
    row_group.font.weight = "bold",
    column_labels.font.weight = "bold",
    table.font.size = 10,
    data_row.padding = px(2)
    ) |> 
  tab_footnote(
    locations = cells_column_spanners(spanners = contains("Agg")),
    footnote = "Aggregate models only performed for violence exposures and depression/anxiety."
      ) |> 
  tab_footnote(
    locations = cells_column_labels(columns = contains("rhat")),
    footnote = md("*Gelman-Rubin diagnostic*. Maximum value for R-hat in model estimates, < 1.01 shows good convergence.")
    ) |>
  tab_footnote(
    locations = cells_column_labels(columns = contains("bulk")),
    footnote = md("*Effective Sample Size*. Minimum value for ESS in model estimates. A value > 400 is sufficient for stable estimations.")
    ) |> 
  tab_footnote(
    locations = cells_column_labels(columns = contains("divergences")),
    footnote = md("*Divergences*. No divergences show good model convergence.")
    ) |>
    cols_hide(columns = "exposure")


tbl_main_dx
Bayes' Diagnostics for weakly informative priors
Doctors
Nurses
Aggregate1
Max R-hat2 Min ESS3 Div.4 Max R-hat2 Min ESS3 Div.4 Max R-hat2 Min ESS3 Div.4
Depression
Bullying Crude 1.01 914 0 1.01 845 0 NA NA NA
Partially adjusted 1.00 966 0 1.01 1,100 0 NA NA NA
Fully adjusted 1.01 1,030 0 1.00 931 0 1.00 1,030 0
Sexual Harassment Crude 1.01 964 0 1.00 981 0 NA NA NA
Partially adjusted 1.01 978 0 1.00 1,052 0 NA NA NA
Fully adjusted 1.01 1,021 0 1.00 1,108 0 1.00 1,115 0
Violent threats Crude 1.01 798 0 1.00 998 0 NA NA NA
Partially adjusted 1.00 1,086 0 1.01 937 0 NA NA NA
Fully adjusted 1.00 967 0 1.00 1,117 0 1.00 1,094 0
Physical violence Crude 1.00 1,077 0 1.00 968 0 NA NA NA
Partially adjusted 1.00 1,261 0 1.00 964 0 NA NA NA
Fully adjusted 1.00 1,074 0 1.00 995 0 1.00 958 0
Colleague support Crude 1.00 879 0 1.00 890 0 NA NA NA
Partially adjusted 1.00 851 0 1.00 1,032 0 NA NA NA
Fully adjusted 1.00 1,139 0 1.00 1,192 0 NA NA NA
Support from superiors Crude 1.01 821 0 1.00 1,054 0 NA NA NA
Partially adjusted 1.00 1,074 0 1.01 1,027 0 NA NA NA
Fully adjusted 1.00 876 0 1.00 1,209 0 NA NA NA
Meaning in work Crude 1.00 967 0 1.00 996 0 NA NA NA
Partially adjusted 1.00 997 0 1.01 950 0 NA NA NA
Fully adjusted 1.00 840 0 1.00 950 0 NA NA NA
Purpose in work Crude 1.00 930 0 1.00 1,045 0 NA NA NA
Partially adjusted 1.01 971 0 1.01 1,142 0 NA NA NA
Fully adjusted 1.00 1,007 0 1.00 1,217 0 NA NA NA
Anxiety
Bullying Crude 1.00 1,130 0 1.00 901 0 NA NA NA
Partially adjusted 1.00 1,010 0 1.00 827 0 NA NA NA
Fully adjusted 1.00 1,112 0 1.00 800 0 1.00 1,226 0
Sexual Harassment Crude 1.00 1,000 0 1.00 1,054 0 NA NA NA
Partially adjusted 1.00 1,128 0 1.00 1,193 0 NA NA NA
Fully adjusted 1.00 1,072 0 1.00 1,101 0 1.00 1,010 0
Violent threats Crude 1.00 1,282 0 1.01 953 0 NA NA NA
Partially adjusted 1.01 1,356 0 1.01 1,083 0 NA NA NA
Fully adjusted 1.00 1,155 0 1.01 1,020 0 1.00 986 0
Physical violence Crude 1.00 978 0 1.01 1,038 0 NA NA NA
Partially adjusted 1.01 959 0 1.01 943 0 NA NA NA
Fully adjusted 1.00 1,069 0 1.00 1,069 0 1.00 991 0
Colleague support Crude 1.01 1,060 0 1.01 1,000 0 NA NA NA
Partially adjusted 1.01 1,083 0 1.00 923 0 NA NA NA
Fully adjusted 1.00 1,009 0 1.00 1,060 0 NA NA NA
Support from superiors Crude 1.01 879 0 1.00 913 0 NA NA NA
Partially adjusted 1.00 1,004 0 1.00 1,080 0 NA NA NA
Fully adjusted 1.00 1,130 0 1.01 1,197 0 NA NA NA
Meaning in work Crude 1.00 955 0 1.00 1,080 0 NA NA NA
Partially adjusted 1.01 1,235 0 1.01 1,129 0 NA NA NA
Fully adjusted 1.00 1,134 0 1.00 1,102 0 NA NA NA
Purpose in work Crude 1.01 1,029 0 1.00 1,183 0 NA NA NA
Partially adjusted 1.00 936 0 1.01 1,201 0 NA NA NA
Fully adjusted 1.01 1,221 0 1.00 1,055 0 NA NA NA
Suicide thoughts
Bullying Crude 1.00 1,356 0 1.00 1,091 0 NA NA NA
Partially adjusted 1.00 1,092 0 1.00 1,116 0 NA NA NA
Fully adjusted 1.00 1,183 0 1.01 1,044 0 NA NA NA
Sexual Harassment Crude 1.00 993 0 1.01 1,202 0 NA NA NA
Partially adjusted 1.00 1,169 0 1.00 953 0 NA NA NA
Fully adjusted 1.00 1,317 0 1.00 918 0 NA NA NA
Violent threats Crude 1.01 1,302 0 1.00 1,039 0 NA NA NA
Partially adjusted 1.01 1,327 0 1.01 1,059 0 NA NA NA
Fully adjusted 1.01 1,572 1 1.00 1,125 0 NA NA NA
Physical violence Crude 1.01 1,099 1 1.00 1,075 0 NA NA NA
Partially adjusted 1.00 1,152 0 1.00 1,076 0 NA NA NA
Fully adjusted 1.00 1,309 0 1.00 1,133 0 NA NA NA
Colleague support Crude 1.00 1,023 0 1.00 886 0 NA NA NA
Partially adjusted 1.00 1,052 0 1.01 1,174 0 NA NA NA
Fully adjusted 1.00 1,314 0 1.00 974 0 NA NA NA
Support from superiors Crude 1.00 1,248 0 1.00 1,040 0 NA NA NA
Partially adjusted 1.00 1,202 0 1.00 1,040 0 NA NA NA
Fully adjusted 1.00 1,216 0 1.00 1,285 0 NA NA NA
Meaning in work Crude 1.00 1,125 0 1.01 1,010 0 NA NA NA
Partially adjusted 1.00 1,103 0 1.00 970 0 NA NA NA
Fully adjusted 1.01 1,023 1 1.00 1,247 0 NA NA NA
Purpose in work Crude 1.01 1,133 0 1.00 1,132 0 NA NA NA
Partially adjusted 1.00 1,092 0 1.00 1,046 0 NA NA NA
Fully adjusted 1.00 1,027 0 1.01 1,182 0 NA NA NA
1 Aggregate models only performed for violence exposures and depression/anxiety.
2 Gelman-Rubin diagnostic. Maximum value for R-hat in model estimates, < 1.01 shows good convergence.
3 Effective Sample Size. Minimum value for ESS in model estimates. A value > 400 is sufficient for stable estimations.
4 Divergences. No divergences show good model convergence.
gtsave(tbl_main_dx, "out/tables/diagnostics_tbl_main_bayes.docx")


tbl_sens_dx <-
  data_sens |>
  mutate(outcome = factor(outcome, levels = outcome_order),
         adjustment = factor(adjustment, levels = adjustment_order),
         exposure = factor(exposure, levels = exposure_order)
         ) |>
  arrange(outcome, exposure, adjustment) |>
  group_by(outcome, exposure) |> 
  mutate(
    exposure_label = ifelse(row_number() == 1, as.character(exposure), "") 
  ) |> 
  ungroup() |> 
  gt(groupname_col = "outcome") |> 
  cols_move_to_start(columns = c(exposure_label, adjustment)) |>  
  tab_spanner(
    label = "Doctors",
    columns = starts_with("Doc")
    ) |>
  tab_spanner(
    label = "Nurses",
    columns = starts_with("Nur")
    ) |>
  cols_label(
    exposure_label = "",
    adjustment = "",
    Doctor_max_rhat = "Max R-hat",
    Doctor_min_ess_bulk = "Min ESS",
    Doctor_divergences = "Div.",
    Nurse_max_rhat = "Max R-hat",
    Nurse_min_ess_bulk = "Min ESS",
    Nurse_divergences = "Div."
    ) |>
  fmt_number(
    columns = ends_with("rhat"),
    decimals = 2
    ) |>
  fmt_integer(
    columns = ends_with("bulk")
    ) |>
  tab_header(
    title = "Bayes' Diagnostics for restrictive priors"
    ) |>
  tab_options(
    row_group.font.weight = "bold",
    column_labels.font.weight = "bold",
    table.font.size = 10,
    data_row.padding = px(2)
    ) |> 
  tab_footnote(
    locations = cells_column_spanners(spanners = contains("Agg")),
    footnote = "Aggregate models only performed for violence exposures and depression/anxiety."
      ) |> 
  tab_footnote(
    locations = cells_column_labels(columns = contains("rhat")),
    footnote = md("*Gelman-Rubin diagnostic*. Maximum value for R-hat in model estimates, < 1.01 shows good convergence.")
    ) |>
  tab_footnote(
    locations = cells_column_labels(columns = contains("bulk")),
    footnote = md("*Effective Sample Size*. Minimum value for ESS in model estimates. A value > 400 is sufficient for stable estimations.")
    ) |> 
  tab_footnote(
    locations = cells_column_labels(columns = contains("divergences")),
    footnote = md("*Divergences*. No divergences show good model convergence.")
    ) |>
    cols_hide(columns = "exposure")

tbl_sens_dx
Bayes' Diagnostics for restrictive priors
Doctors
Nurses
Max R-hat1 Min ESS2 Div.3 Max R-hat1 Min ESS2 Div.3
Depression
Bullying Crude 1.01 804 0 1.00 1,198 0
Partially adjusted 1.01 922 0 1.00 1,030 0
Fully adjusted 1.00 1,001 0 1.00 1,046 0
Sexual Harassment Crude 1.01 779 0 1.00 1,005 0
Partially adjusted 1.00 893 0 1.00 855 0
Fully adjusted 1.00 896 0 1.00 925 0
Violent threats Crude 1.00 1,003 0 1.00 1,202 0
Partially adjusted 1.00 876 0 1.00 1,187 0
Fully adjusted 1.01 933 0 1.00 904 0
Physical violence Crude 1.00 1,191 0 1.00 1,012 0
Partially adjusted 1.00 1,073 0 1.00 1,125 0
Fully adjusted 1.00 1,123 0 1.00 1,165 0
Colleague support Crude 1.00 853 0 1.01 908 0
Partially adjusted 1.01 1,093 0 1.00 1,120 0
Fully adjusted 1.00 834 0 1.01 1,140 0
Support from superiors Crude 1.01 855 0 1.00 1,053 0
Partially adjusted 1.00 958 0 1.00 977 0
Fully adjusted 1.00 865 0 1.01 975 0
Meaning in work Crude 1.00 1,111 0 1.00 985 0
Partially adjusted 1.01 967 0 1.00 1,025 0
Fully adjusted 1.00 1,086 0 1.00 1,027 0
Purpose in work Crude 1.00 879 0 1.00 1,134 0
Partially adjusted 1.00 927 0 1.00 1,077 0
Fully adjusted 1.00 1,120 0 1.00 1,260 0
Anxiety
Bullying Crude 1.00 1,206 0 1.00 1,064 0
Partially adjusted 1.00 1,071 0 1.01 1,048 0
Fully adjusted 1.00 891 0 1.00 955 0
Sexual Harassment Crude 1.01 934 0 1.00 862 0
Partially adjusted 1.00 1,039 0 1.00 988 0
Fully adjusted 1.01 1,160 0 1.00 1,098 0
Violent threats Crude 1.00 957 0 1.00 959 0
Partially adjusted 1.00 1,219 0 1.00 906 0
Fully adjusted 1.00 1,149 0 1.00 1,162 0
Physical violence Crude 1.00 941 0 1.00 904 0
Partially adjusted 1.00 916 0 1.00 964 0
Fully adjusted 1.00 984 0 1.00 1,194 0
Colleague support Crude 1.00 1,064 0 1.00 991 0
Partially adjusted 1.00 849 0 1.01 1,184 0
Fully adjusted 1.00 1,104 0 1.00 1,065 0
Support from superiors Crude 1.00 954 0 1.00 1,050 0
Partially adjusted 1.00 1,014 0 1.00 1,075 0
Fully adjusted 1.00 1,126 0 1.00 1,182 0
Meaning in work Crude 1.00 1,067 0 1.00 1,156 0
Partially adjusted 1.00 1,072 0 1.00 1,016 0
Fully adjusted 1.00 1,158 0 1.00 1,299 0
Purpose in work Crude 1.00 1,077 0 1.00 1,135 0
Partially adjusted 1.00 969 0 1.00 1,124 0
Fully adjusted 1.00 1,183 0 1.00 1,075 0
1 Gelman-Rubin diagnostic. Maximum value for R-hat in model estimates, < 1.01 shows good convergence.
2 Effective Sample Size. Minimum value for ESS in model estimates. A value > 400 is sufficient for stable estimations.
3 Divergences. No divergences show good model convergence.
gtsave(tbl_sens_dx, "out/tables/diagnostics_tbl_sens_bayes.docx")

Absolute risks

brm_results_df <- readRDS("out/dataframes/brm_results.rds")

survey_results_df <- readRDS("out/dataframes/svy_results_df.rds")

glm_results_df <- readRDS("out/dataframes/glm_multilevel_df.rds")

# clean
brm_risks <- 
  brm_results_df |> 
  filter(Model == "Fully adjusted") |> 
  select(Outcome, Exposure, Profession, Risk_Unexposed, Risk_Exposed)|>
  rename(Unexposed_Bayesian = Risk_Unexposed,
         Exposed_Bayesian = Risk_Exposed) |> 
  mutate(Exposed_Bayesian = as.numeric(str_replace(Exposed_Bayesian, "%",
                                                   "")),
         Unexposed_Bayesian = as.numeric(str_replace(Unexposed_Bayesian, "%",
                                                   ""))) |> 
  mutate(ARR_Bayesian = abs(Exposed_Bayesian - Unexposed_Bayesian)) |> 
  mutate(Exposure = case_when(
    Exposure == "Harassment" ~ "Sexual Harassment",
    TRUE ~ Exposure
  ))



svy_risks <-
  survey_results_df |> 
  filter(Model == "Fully Adj.") |> 
  select(Outcome, Exposure, Profession, Risk_Unexposed, Risk_Exposed) |> 
  rename(Unexposed_Survey = Risk_Unexposed,
         Exposed_Survey = Risk_Exposed) |> 
  mutate(Exposed_Survey = as.numeric(str_replace(Exposed_Survey, "%",
                                                   "")),
         Unexposed_Survey = as.numeric(str_replace(Unexposed_Survey, "%",
                                                   ""))) |> 
  mutate(ARR_Survey = abs(Exposed_Survey - Unexposed_Survey))


glm_risks <- 
  glm_results_df |> 
  filter(Adjustment == "Fully adjusted") |>
  select(Outcome, Exposure, Profession, Risk_Unexp, Risk_Exp) |> 
  rename(Unexposed_GLM = Risk_Unexp,
         Exposed_GLM = Risk_Exp) |> 
  mutate(Exposed_GLM = as.numeric(str_replace(Exposed_GLM, "%",
                                                   "")),
         Unexposed_GLM = as.numeric(str_replace(Unexposed_GLM, "%",
                                                   ""))) |> 
  mutate(ARR_GLM = abs(Exposed_GLM - Unexposed_GLM)) |> 
   mutate(
    Exposure = case_when(
      Exposure == "work_21_dic" ~ "Colleague support",
      Exposure == "work_22_dic" ~ "Support from superiors",
      Exposure == "work_31_dic" ~ "Violent threats",
      Exposure == "work_32_dic" ~ "Physical violence",
      Exposure == "work_30_dic" ~ "Sexual Harassment",
      Exposure == "work_33_dic" ~ "Bullying",
      Exposure == "wb_wami_1_dic" ~ "Meaning in work",
      Exposure == "wb_wami_2_dic" ~ "Purpose in work",
      TRUE ~ Exposure),
    Outcome = case_when(
      Outcome == "phq_co" ~ "Depression",
      Outcome == "gad_co" ~ "Anxiety",
      Outcome == "suic_idea" ~ "Suicide thoughts",
      TRUE ~ Outcome
    )
   )



exposures_risks <-
  brm_risks |> 
  left_join(svy_risks, by = c("Outcome", "Exposure", "Profession")) |> 
  left_join(glm_risks, by = c("Outcome", "Exposure", "Profession"))
  

exposures_risks
## # A tibble: 48 × 12
##    Outcome Exposure  Profession Unexposed_Bayesian Exposed_Bayesian ARR_Bayesian
##    <chr>   <chr>     <chr>                   <dbl>            <dbl>        <dbl>
##  1 Anxiety Bullying  Doctor                   18.3             42.3         24  
##  2 Anxiety Bullying  Nurse                    12.5             35.1         22.6
##  3 Anxiety Colleagu… Doctor                   32               19.9         12.1
##  4 Anxiety Colleagu… Nurse                    22.2             12.6          9.6
##  5 Anxiety Sexual H… Doctor                   22.7             44.2         21.5
##  6 Anxiety Sexual H… Nurse                    15.1             38.5         23.4
##  7 Anxiety Meaning … Doctor                   41               19.4         21.6
##  8 Anxiety Meaning … Nurse                    26.5             12.2         14.3
##  9 Anxiety Purpose … Doctor                   46.6             20.5         26.1
## 10 Anxiety Purpose … Nurse                    28.4             13.9         14.5
## # ℹ 38 more rows
## # ℹ 6 more variables: Unexposed_Survey <dbl>, Exposed_Survey <dbl>,
## #   ARR_Survey <dbl>, Unexposed_GLM <dbl>, Exposed_GLM <dbl>, ARR_GLM <dbl>
arr_tbl <-

  glm_risks |> 
  pivot_wider(
    names_from = Profession,
    values_from = c("Unexposed_GLM", "Exposed_GLM", "ARR_GLM")
  ) |> 
  mutate(
    across(
      where(is.numeric),
      ~ as.character(paste0(round(.x, 1), "%"))
    )
  ) |> 
  mutate(Outcome = factor(Outcome, levels = outcome_order), 
         Exposure = factor(Exposure, levels = exposure_order)
         ) |>
  arrange(Outcome, Exposure) |> 
  gt(groupname_col = "Outcome",
     rowname_col = "Exposure") |>
  tab_header(title = md("**Absolute prevalence and prevalence difference for each exposure-outcome pair**")) |>
      tab_spanner(
        label = md("**Doctor**"),
        columns = ends_with("Doctor")
      ) |> 
      tab_spanner(
        label = md("**Nurse**"),
        columns = ends_with("Nurse")
      ) |> 
      cols_label(
        starts_with("Unexposed") ~ "Unexposed",
        starts_with("Exposed") ~ "Exposed",
        starts_with("ARR") ~ "Difference"
      ) |> 
      cols_align(
        align = "center",
        columns = contains(c("_Doctor", "_Nurse"))
      ) |> 
      tab_style(
        style = cell_text(align = "left"),
        locations = cells_stub()
        ) |>
      tab_stub_indent(
        rows = everything(), 
        indent = 3
      ) |> 
      tab_footnote(
        locations = cells_column_labels(
          columns = matches("ARR")
        ),
        footnote = md("*Prevalence difference*")
      ) |>
      tab_footnote(footnote = "Estimates from fully adjusted multilevel models.")


arr_tbl
Absolute prevalence and prevalence difference for each exposure-outcome pair
Doctor
Nurse
Unexposed Exposed Difference1 Unexposed Exposed Difference1
Depression
Bullying 27.4% 55.3% 27.9% 17.9% 44.6% 26.7%
Sexual Harassment 33.6% 50% 16.4% 21.4% 44.5% 23.1%
Violent threats 30% 55.3% 25.3% 20.4% 43.4% 23%
Physical violence 34.9% 52.1% 17.2% 22.3% 45.2% 22.9%
Colleague support 44.4% 29.2% 15.2% 30.3% 18% 12.3%
Support from superiors 43.9% 27.1% 16.8% 30.5% 15.8% 14.7%
Meaning in work 55% 27.5% 27.5% 37.3% 16.3% 21%
Purpose in work 60.9% 29.4% 31.5% 39.4% 19.3% 20.1%
Anxiety
Bullying 18.8% 39.5% 20.7% 12.7% 33.7% 21%
Sexual Harassment 23.2% 37.6% 14.4% 15.3% 34.9% 19.6%
Violent threats 20.7% 39.9% 19.2% 14.6% 33.1% 18.5%
Physical violence 24.2% 43.3% 19.1% 16.1% 34.5% 18.4%
Colleague support 31.2% 20.4% 10.8% 22.2% 12.8% 9.4%
Support from superiors 31.3% 18.6% 12.7% 22.2% 11.4% 10.8%
Meaning in work 39.6% 19.6% 20% 26.3% 12.3% 14%
Purpose in work 44.3% 20.7% 23.6% 27.8% 14.2% 13.6%
Suicide thoughts
Bullying 9.1% 20.2% 11.1% 5.9% 18.4% 12.5%
Sexual Harassment 11% 23.4% 12.4% 7.4% 20.5% 13.1%
Violent threats 9.8% 21.3% 11.5% 7% 18% 11%
Physical violence 11.7% 27.8% 16.1% 7.9% 21.1% 13.2%
Colleague support 15.7% 10.1% 5.6% 11.6% 6.1% 5.5%
Support from superiors 15.4% 9.4% 6% 10.9% 6% 4.9%
Meaning in work 20.9% 9.2% 11.7% 12.8% 6% 6.8%
Purpose in work 24.9% 9.7% 15.2% 15.2% 6.7% 8.5%
Estimates from fully adjusted multilevel models.
1 Prevalence difference
gtsave(arr_tbl, "out/dataframes/arr_table_long.docx")

Sensitivity forest plot

brm_res <- readRDS("out/dataframes/brm_results.rds") |> 
  filter(Type == "PR", Model == "Fully adjusted") |> 
  select(Outcome, Exposure, Profession, Est_CI) |> 
  mutate(Analysis = "Bayesian main (Weakly informative priors)")


brm_sens <- readRDS("out/dataframes/bay_res_sens.rds") |> 
  mutate(
    Analysis = "Bayesian sensitivity (Restrictive priors)")
  

svy_res <- readRDS("out/dataframes/svy_results_df.rds") |> 
  filter(Type == "PR", Model == "Fully Adj.") |> 
  select(-c(Model, Type), -contains("Risk_")) |> 
  mutate(Analysis = "Survey design regression")

glm_res <- readRDS("out/dataframes/glm_results_df.rds") |> 
  filter(Adjustment == "Fully adjusted") |>
  select(Outcome, Exposure, Profession, Est_CI) |> 
  mutate(Analysis = "GLM")


sens_df <-
  brm_res |> 
  bind_rows(brm_sens, svy_res, glm_res) |> 
  mutate(Outcome = case_when(
    str_detect(Outcome, "Ideation") ~ "Suicide thoughts",
    TRUE ~ Outcome),
    Exposure = if_else(Exposure == "Harassment", 
                       "Sexual Harassment",
                       Exposure))
  
sens_df
## # A tibble: 176 × 5
##    Outcome Exposure          Profession Est_CI            Analysis              
##    <chr>   <chr>             <chr>      <chr>             <chr>                 
##  1 Anxiety Bullying          Doctor     2.09 (1.91, 2.28) Bayesian main (Weakly…
##  2 Anxiety Bullying          Nurse      2.64 (2.40, 2.92) Bayesian main (Weakly…
##  3 Anxiety Colleague support Doctor     0.65 (0.60, 0.71) Bayesian main (Weakly…
##  4 Anxiety Colleague support Nurse      0.58 (0.53, 0.63) Bayesian main (Weakly…
##  5 Anxiety Sexual Harassment Doctor     1.61 (1.42, 1.81) Bayesian main (Weakly…
##  6 Anxiety Sexual Harassment Nurse      2.25 (1.97, 2.57) Bayesian main (Weakly…
##  7 Anxiety Meaning in work   Doctor     0.50 (0.45, 0.56) Bayesian main (Weakly…
##  8 Anxiety Meaning in work   Nurse      0.47 (0.42, 0.53) Bayesian main (Weakly…
##  9 Anxiety Purpose in work   Doctor     0.47 (0.42, 0.53) Bayesian main (Weakly…
## 10 Anxiety Purpose in work   Nurse      0.51 (0.45, 0.59) Bayesian main (Weakly…
## # ℹ 166 more rows
forest_sens_comp <-
  
  sens_df |>
    filter(Outcome != "Suicide thoughts") |> 
  # extract numeric estimates for plotting
  mutate(
    PR = as.numeric(str_extract(Est_CI, "^[0-9\\.]+")),
    Lower = as.numeric(str_extract(Est_CI, "(?<=\\()[0-9\\.]+")),
    Upper = as.numeric(str_extract(Est_CI, "[0-9\\.]+(?=\\))"))
  ) |>
  mutate(Outcome = factor(Outcome, levels = c("Depression", "Anxiety")),
         Exposure = factor(Exposure, levels = rev(exposure_order)),
         Analysis = factor(
           Analysis,
           levels = c("GLM",
                      "Survey design regression",
                      "Bayesian main (Weakly informative priors)",
                      "Bayesian sensitivity (Restrictive priors)"))) |>
  arrange(Outcome, Exposure, Analysis) |> 
  ggplot(aes(x = PR, 
             y = Exposure, 
             shape = Analysis)) +
  geom_point(position = position_dodge(width = 0.5), 
             size = 3) +
  geom_errorbar(aes(xmin = Lower, 
                    xmax = Upper), 
                 position = position_dodge(width = 0.5)) +
  facet_wrap(~Profession + Outcome, 
             scales = "free_y") +
  geom_vline(xintercept = 1, 
             linetype = "dashed") +
  scale_x_log10(breaks = c(0.2, 0.5, 1, 2, 4), 
                labels = scales::label_number(
                  accuracy = 0.1,
                  decimal.mark = "·"
                )) +
  theme(
    legend.text = element_text(size = 10),
    legend.margin = margin(b = -5), # pulls legend close to plot
    plot.margin = margin(0, 0.1, 0, 0, "cm"),
    panel.spacing.x = unit(0.5, "cm"),
    strip.text = element_text(size = 10),
    axis.title.x = element_text(size = 10),
    axis.text.x = element_text(size = 10),
    axis.title.y = element_text(size = 10),
    axis.text.y = element_text(size = 10)
  ) +
  ggpubr::theme_pubr()


forest_sens_comp

ggsave(filename = "forest_sens_comparison.pdf",
       plot = forest_sens_comp,
       path = "out/plots/",
       width = 210,
       height = 170,
       units = "mm",
       dpi = 320,
       scale = 2.2
       )


forest_sens_suic <-
  
  sens_df |>
    filter(Outcome == "Suicide thoughts") |> 
  # extract numeric estimates for plotting
  mutate(
    PR = as.numeric(str_extract(Est_CI, "^[0-9\\.]+")),
    Lower = as.numeric(str_extract(Est_CI, "(?<=\\()[0-9\\.]+")),
    Upper = as.numeric(str_extract(Est_CI, "[0-9\\.]+(?=\\))"))
  ) |> 
    mutate(Exposure = factor(Exposure, levels = rev(exposure_order)),
           Analysis = factor(
             Analysis,
             levels = c("GLM",
                        "Survey design regression",
                        "Bayesian main (Weakly informative priors)",
                        "Bayesian sensitivity (Restrictive priors)"))) |> 
  ggplot(aes(x = PR, 
             y = Exposure,
             shape = Analysis)) +
  geom_point(position = position_dodge(width = 0.5), size = 3) +
  geom_errorbar(aes(xmin = Lower, xmax = Upper), 
                 position = position_dodge(width = 0.5)) +
  facet_wrap(~Profession + Outcome, scales = "free_y") +
  geom_vline(xintercept = 1, linetype = "dashed") +
  scale_x_log10(breaks = c(0.2, 0.5, 1, 2, 4), 
                labels = scales::label_number(
                  accuracy = 0.1,
                  decimal.mark = "·"
                )) +
  theme(
    legend.text = element_text(size = 10),
    legend.margin = margin(b = -5), # pulls legend close to plot
    plot.margin = margin(0, 0.1, 0, 0, "cm"),
    panel.spacing.x = unit(0.5, "cm"),
    strip.text = element_text(size = 10),
    axis.title.x = element_text(size = 10),
    axis.text.x = element_text(size = 10),
    axis.title.y = element_text(size = 10),
    axis.text.y = element_text(size = 10)
  ) +
  ggpubr::theme_pubr() 

forest_sens_suic

ggsave(filename = "forest_sens_comparison_suic.pdf",
       plot = forest_sens_suic,
       path = "out/plots/",
       width = 210,
       height = 170,
       units = "mm",
       dpi = 320,
       scale = 1.5
       )

Sensitivity table

tbl_sensitivity_all <-
  
  sens_df |>
  select(Outcome, Exposure, Profession, Analysis, Est_CI) |> 
  # Pivot to wide format
  pivot_wider(
    names_from = c(Profession, Analysis),
    values_from = Est_CI,
    names_sep = "_"
  ) |>
  # Order columns logically
  select(Outcome, Exposure, 
         contains("Doctor_GLM"), contains("Doctor_Survey"),  
         contains("Doctor_Bayesian main"), contains("Doctor_Bayesian sens"), 
         contains("Nurse_GLM"), contains("Nurse_Survey"),
         contains("Nurse_Bayesian main"), contains("Nurse_Bayesian sens") 
         ) |>
  mutate(Outcome = factor(Outcome, levels = outcome_order), 
         Exposure = factor(Exposure, levels = exposure_order)) |>
  arrange(Outcome, Exposure) |> 
  # Create Table
  gt(groupname_col = "Outcome", rowname_col = "Exposure") |>
  
  # Headers
  tab_header(
    title = md("**Sensitivity Analysis: All methods**"),
    subtitle = "Fully Adjusted Prevalence Ratios (95% CI or CrI)"
  ) |>
  
  # Spanners for Profession
  tab_spanner(
    label = md("**Doctor**"),
    columns = starts_with("Doctor")
  ) |>
  tab_spanner(
    label = md("**Nurse**"),
    columns = starts_with("Nurse")
  ) |>
  
  # Clean Column Labels (Remove the "Doctor_" prefix)
  cols_label(
    `Doctor_Bayesian main (Weakly informative priors)` = 
      "Bayesian (Weak priors)",
    `Doctor_Bayesian sensitivity (Restrictive priors)` = 
      "Bayesian (Restrictive)",
    `Doctor_Survey design regression` = "Survey design",
    `Doctor_GLM` = "GLM Multilevel",
    `Nurse_Bayesian main (Weakly informative priors)` = 
      "Bayesian (Weak priors)",
    `Nurse_Bayesian sensitivity (Restrictive priors)` = 
      "Bayesian (Restrictive)",
    `Nurse_Survey design regression` = "Survey design",
    `Nurse_GLM` = "GLM Multilevel",
  ) |>
  
  # Formatting
  cols_align(align = "center", columns = contains("_")) |>
  tab_stub_indent(rows = everything(), indent = 3) |>
  tab_footnote(
    footnote = "Fully adjusted models."
  ) |> 
  tab_footnote(
    footnote = "Multilevel GLM.",
    locations = cells_column_labels(columns = contains("GLM"))
  ) |> 
  tab_footnote(
    footnote ="Survey design applied with multivariate regression.",
    locations = cells_column_labels(columns = contains("Survey"))
  ) |> 
  tab_footnote(
    footnote =  "Bayesian Restrictive: Doctors use informative intercepts based on prevalence (Anxiety and depression, no information on suicide thoughts) + Skeptical Betas; Nurses use Skeptical Betas. ",
    locations = cells_column_labels(columns = contains("Restrictive"))
  )

tbl_sensitivity_all
Sensitivity Analysis: All methods
Fully Adjusted Prevalence Ratios (95% CI or CrI)
Doctor
Nurse
GLM Multilevel1 Survey design2 Bayesian (Weak priors) Bayesian (Restrictive)3 GLM Multilevel1 Survey design2 Bayesian (Weak priors) Bayesian (Restrictive)3
Depression
Bullying 2.02 (1.88, 2.18) 2.03 (1.93, 2.14) 2.02 (1.87, 2.17) 2.00 (1.86, 2.15) 2.49 (2.30, 2.71) 2.53 (2.26, 2.83) 2.48 (2.28, 2.69) 2.44 (2.26, 2.65)
Sexual Harassment 1.49 (1.34, 1.65) 1.49 (1.39, 1.61) 1.48 (1.34, 1.65) 1.47 (1.33, 1.63) 2.08 (1.86, 2.33) 2.11 (1.91, 2.33) 2.06 (1.84, 2.31) 2.03 (1.81, 2.27)
Violent threats 1.85 (1.71, 2.00) 1.86 (1.75, 1.98) 1.84 (1.70, 1.99) 1.83 (1.69, 1.97) 2.12 (1.93, 2.34) 2.17 (2.05, 2.31) 2.11 (1.91, 2.32) 2.07 (1.88, 2.29)
Physical violence 1.49 (1.27, 1.76) 1.50 (1.30, 1.72) 1.48 (1.25, 1.73) 1.44 (1.23, 1.67) 2.02 (1.74, 2.36) 2.08 (1.87, 2.33) 1.99 (1.69, 2.33) 1.91 (1.65, 2.21)
Colleague support 0.66 (0.61, 0.71) 0.66 (0.61, 0.71) 0.66 (0.61, 0.71) 0.66 (0.62, 0.71) 0.59 (0.55, 0.64) 0.60 (0.55, 0.64) 0.60 (0.55, 0.65) 0.60 (0.56, 0.65)
Support from superiors 0.62 (0.57, 0.67) 0.62 (0.57, 0.67) 0.62 (0.57, 0.67) 0.62 (0.58, 0.67) 0.52 (0.48, 0.56) 0.52 (0.47, 0.57) 0.52 (0.48, 0.56) 0.52 (0.48, 0.57)
Meaning in work 0.50 (0.46, 0.55) 0.50 (0.47, 0.53) 0.50 (0.46, 0.55) 0.51 (0.47, 0.56) 0.44 (0.40, 0.48) 0.44 (0.40, 0.49) 0.44 (0.40, 0.48) 0.45 (0.41, 0.49)
Purpose in work 0.48 (0.44, 0.53) 0.48 (0.45, 0.51) 0.48 (0.44, 0.54) 0.49 (0.45, 0.55) 0.49 (0.44, 0.55) 0.49 (0.45, 0.53) 0.49 (0.44, 0.55) 0.50 (0.45, 0.56)
Anxiety
Bullying 2.10 (1.92, 2.29) 2.11 (1.96, 2.28) 2.09 (1.91, 2.28) 2.06 (1.89, 2.25) 2.66 (2.42, 2.93) 2.69 (2.42, 2.99) 2.64 (2.40, 2.92) 2.58 (2.34, 2.84)
Sexual Harassment 1.62 (1.44, 1.82) 1.62 (1.49, 1.77) 1.61 (1.42, 1.81) 1.59 (1.42, 1.78) 2.28 (2.00, 2.60) 2.30 (1.99, 2.65) 2.25 (1.97, 2.57) 2.18 (1.91, 2.48)
Violent threats 1.93 (1.76, 2.12) 1.94 (1.77, 2.11) 1.92 (1.75, 2.11) 1.89 (1.72, 2.08) 2.27 (2.03, 2.54) 2.31 (2.17, 2.47) 2.25 (1.99, 2.52) 2.19 (1.96, 2.43)
Physical violence 1.79 (1.49, 2.15) 1.81 (1.60, 2.04) 1.75 (1.46, 2.09) 1.67 (1.39, 1.98) 2.14 (1.80, 2.56) 2.18 (1.84, 2.58) 2.08 (1.75, 2.46) 1.96 (1.65, 2.32)
Colleague support 0.65 (0.60, 0.71) 0.65 (0.61, 0.69) 0.65 (0.60, 0.71) 0.66 (0.61, 0.72) 0.57 (0.52, 0.63) 0.58 (0.52, 0.64) 0.58 (0.53, 0.63) 0.58 (0.53, 0.64)
Support from superiors 0.60 (0.54, 0.65) 0.59 (0.55, 0.64) 0.60 (0.54, 0.65) 0.60 (0.55, 0.65) 0.51 (0.47, 0.57) 0.51 (0.47, 0.57) 0.52 (0.47, 0.57) 0.52 (0.48, 0.57)
Meaning in work 0.50 (0.45, 0.55) 0.49 (0.45, 0.54) 0.50 (0.45, 0.56) 0.51 (0.46, 0.57) 0.47 (0.42, 0.53) 0.47 (0.42, 0.54) 0.47 (0.42, 0.53) 0.49 (0.44, 0.54)
Purpose in work 0.47 (0.41, 0.53) 0.47 (0.42, 0.52) 0.47 (0.42, 0.53) 0.49 (0.43, 0.55) 0.51 (0.45, 0.58) 0.51 (0.45, 0.58) 0.51 (0.45, 0.59) 0.53 (0.47, 0.60)
Suicide thoughts
Bullying 2.22 (1.96, 2.51) 2.22 (1.95, 2.53) 2.20 (1.94, 2.48) NA 3.11 (2.73, 3.56) 3.17 (2.69, 3.74) 3.05 (2.69, 3.46) NA
Sexual Harassment 2.13 (1.83, 2.48) 2.15 (1.99, 2.32) 2.10 (1.81, 2.45) NA 2.78 (2.35, 3.30) 2.80 (2.34, 3.36) 2.72 (2.30, 3.21) NA
Violent threats 2.18 (1.92, 2.48) 2.18 (1.94, 2.44) 2.16 (1.90, 2.44) NA 2.56 (2.20, 2.99) 2.63 (2.18, 3.16) 2.52 (2.16, 2.92) NA
Physical violence 2.37 (1.90, 2.95) 2.35 (1.99, 2.77) 2.26 (1.81, 2.79) NA 2.68 (2.16, 3.34) 2.74 (2.13, 3.53) 2.56 (2.05, 3.19) NA
Colleague support 0.64 (0.57, 0.72) 0.64 (0.57, 0.71) 0.64 (0.57, 0.72) NA 0.52 (0.46, 0.60) 0.52 (0.45, 0.61) 0.53 (0.46, 0.60) NA
Support from superiors 0.61 (0.54, 0.69) 0.61 (0.53, 0.71) 0.61 (0.54, 0.69) NA 0.55 (0.48, 0.63) 0.55 (0.47, 0.65) 0.56 (0.49, 0.63) NA
Meaning in work 0.44 (0.38, 0.51) 0.44 (0.38, 0.51) 0.45 (0.38, 0.52) NA 0.47 (0.40, 0.55) 0.47 (0.41, 0.54) 0.48 (0.41, 0.56) NA
Purpose in work 0.39 (0.33, 0.46) 0.39 (0.34, 0.45) 0.40 (0.34, 0.47) NA 0.44 (0.37, 0.52) 0.44 (0.39, 0.50) 0.45 (0.38, 0.54) NA
Fully adjusted models.
1 Multilevel GLM.
2 Survey design applied with multivariate regression.
3 Bayesian Restrictive: Doctors use informative intercepts based on prevalence (Anxiety and depression, no information on suicide thoughts) + Skeptical Betas; Nurses use Skeptical Betas.
# Save
gtsave(tbl_sensitivity_all, "out/tables/sensitivity_comparison_all.docx")

Maps

Aggregated prevalences

Exposures and Outcomes

darkblue = "#0045A8"
aqua = "#38aec5"
cyan = "#00C4D6"



# IMPORTANT:
# First time running this code, installation needs to be like this:


# install.packages(
#   "rnaturalearthhires",
#   repos = "https://ropensci.r-universe.dev",
#   type = "source"
# )


ukraine <- rnaturalearth::ne_states(country = "ukraine", 
                                  returnclass = "sf")

# crimea is included as russia (wrong)
crimea <- 
  rnaturalearth::ne_states(country = "russia",
                                   returnclass = "sf") |> 
  filter(name == "Crimea") |> 
  select(fips, geometry)



# get data
exp_reg <- readRDS("out/dataframes/exposure_regions.rds") |> 
  pivot_longer(
    cols = starts_with("work_"),
    names_to = "Exposure",
    values_to = "Prevalence"
  ) |> 
  mutate(Exposure = case_when(
    Exposure == "work_30_dic" ~ "Sexual Harassment",
    Exposure == "work_31_dic" ~ "Violent threats",
    Exposure == "work_32_dic" ~ "Physical violence",
    Exposure == "work_33_dic" ~ "Bullying",
  ))

out_prev_agg <- c("phq_co", "gad_co", "suic_idea")

out_reg <- readRDS("out/dataframes/outcome_regions.rds") |> 
  pivot_longer(
    cols = all_of(out_prev_agg),
    names_to = "Outcome",
    values_to = "Prevalence"
  ) |> 
  mutate(Outcome = case_when(
    Outcome == "phq_co" ~ "Depression",
    Outcome == "gad_co" ~ "Anxiety",
    Outcome == "suic_idea" ~ "Suicide thoughts",
  ))


# join with geometry data
map_info_prev_exp <- 
  ukraine |>
  select(fips, geometry) |>   
  bind_rows(crimea) |> 
  rename(fips_code = fips) |>        
  inner_join(exp_reg, by = "fips_code")

map_info_prev_exp
## Simple feature collection with 104 features and 5 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: 22.13284 ymin: 44.38105 xmax: 40.15954 ymax: 52.36895
## Geodetic CRS:  WGS 84
## First 10 features:
##    fips_code           loc_en                loc_3          Exposure Prevalence
## 1       UP02 Chernihiv Oblast Чернігівська Область Sexual Harassment 0.06405694
## 2       UP02 Chernihiv Oblast Чернігівська Область   Violent threats 0.15995261
## 3       UP02 Chernihiv Oblast Чернігівська Область Physical violence 0.03554502
## 4       UP02 Chernihiv Oblast Чернігівська Область          Bullying 0.23186683
## 5       UP24     Volyn Oblast    Волинська Область Sexual Harassment 0.06364617
## 6       UP24     Volyn Oblast    Волинська Область   Violent threats 0.13852814
## 7       UP24     Volyn Oblast    Волинська Область Physical violence 0.02918919
## 8       UP24     Volyn Oblast    Волинська Область          Bullying 0.22619048
## 9       UP19     Rivne Oblast   Рівненська Область Sexual Harassment 0.04597701
## 10      UP19     Rivne Oblast   Рівненська Область   Violent threats 0.11304348
##                          geometry
## 1  MULTIPOLYGON (((31.47485 52...
## 2  MULTIPOLYGON (((31.47485 52...
## 3  MULTIPOLYGON (((31.47485 52...
## 4  MULTIPOLYGON (((31.47485 52...
## 5  MULTIPOLYGON (((25.1833 51....
## 6  MULTIPOLYGON (((25.1833 51....
## 7  MULTIPOLYGON (((25.1833 51....
## 8  MULTIPOLYGON (((25.1833 51....
## 9  MULTIPOLYGON (((25.5474 51....
## 10 MULTIPOLYGON (((25.5474 51....
map_info_prev_out <- 
  ukraine |>
  select(fips, geometry) |>   
  bind_rows(crimea) |> 
  rename(fips_code = fips) |>        
  inner_join(out_reg, by = "fips_code")

map_info_prev_out
## Simple feature collection with 78 features and 5 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: 22.13284 ymin: 44.38105 xmax: 40.15954 ymax: 52.36895
## Geodetic CRS:  WGS 84
## First 10 features:
##    fips_code           loc_en                loc_3          Outcome Prevalence
## 1       UP02 Chernihiv Oblast Чернігівська Область       Depression 0.32509271
## 2       UP02 Chernihiv Oblast Чернігівська Область          Anxiety 0.24351051
## 3       UP02 Chernihiv Oblast Чернігівська Область Suicide thoughts 0.11960543
## 4       UP24     Volyn Oblast    Волинська Область       Depression 0.27633069
## 5       UP24     Volyn Oblast    Волинська Область          Anxiety 0.16742081
## 6       UP24     Volyn Oblast    Волинська Область Suicide thoughts 0.08558559
## 7       UP19     Rivne Oblast   Рівненська Область       Depression 0.24776119
## 8       UP19     Rivne Oblast   Рівненська Область          Anxiety 0.18154762
## 9       UP19     Rivne Oblast   Рівненська Область Suicide thoughts 0.09523810
## 10      UP27  Zhytomyr Oblast  Житомирська Область       Depression 0.33299697
##                          geometry
## 1  MULTIPOLYGON (((31.47485 52...
## 2  MULTIPOLYGON (((31.47485 52...
## 3  MULTIPOLYGON (((31.47485 52...
## 4  MULTIPOLYGON (((25.1833 51....
## 5  MULTIPOLYGON (((25.1833 51....
## 6  MULTIPOLYGON (((25.1833 51....
## 7  MULTIPOLYGON (((25.5474 51....
## 8  MULTIPOLYGON (((25.5474 51....
## 9  MULTIPOLYGON (((25.5474 51....
## 10 MULTIPOLYGON (((27.66615 51...
# maps
#outcomes

outcomes_gen_map <-
  
  map_info_prev_out |> 
  mutate(Outcome = factor(Outcome, levels = outcome_order)) |>
  arrange(Outcome) |> 
  ggplot() +
  geom_sf(aes(fill = Prevalence), color = "white", size = 0.2) +  
  scale_fill_gradient(low = "#dae6f2",
                      high = darkblue,
                      na.value = "turquoise1",
                      labels = scales::percent,
                      limits = c(0, 0.5)) +
  geom_sf_text(
    aes(
      label = ifelse(
        is.na(Prevalence),
        "ND",
        scales::percent(Prevalence, accuracy = 1)
        )
      ),
    size = 3,
    check_overlap = TRUE
    ) +
  scale_color_manual(values = c("black", "white"), guide = "none") +
  facet_wrap(~Outcome, ncol = 2) +
  labs(
    fill = "Prevalence") +
  ggpubr::theme_pubr() +
  theme(
    legend.position = "right",
    legend.text = element_text(size = 10),
    axis.title = element_blank(), 
    axis.text = element_blank(),  
    axis.ticks = element_blank(),
    axis.line = element_blank(),
    strip.text = element_text(size = 10, face = "bold"),
  ) 

outcomes_gen_map

ggsave(
  "outcomes_map.pdf",
  plot = outcomes_gen_map,
  path = "out/",
  scale = 1.7,
  width = 210,
  height = 160,
  unit = "mm",
  dpi = 350
)


# exposures

exposures_gen_map <-
  map_info_prev_exp |> 
  mutate(Exposure = factor(Exposure, levels = exposure_order)) |> 
  arrange(Exposure) |> 
  ggplot() +
  geom_sf(aes(fill = Prevalence), color = "white", size = 0.2) +  
  scale_fill_gradient(low = "#dae6f2",
                      high = darkblue,
                      na.value = "turquoise1",
                      labels = scales::percent,
                      limits = c(0, 0.5)) +
  geom_sf_text(
    aes(
      label = ifelse(
        is.na(Prevalence),
        "ND",
        scales::percent(Prevalence, accuracy = 1)
        )
      ),
    size = 3,
    check_overlap = TRUE
    ) +
  scale_color_manual(values = c("black", "white"), guide = "none") +
  facet_wrap(~Exposure, ncol = 2) +
  labs(
    fill = "Prevalence") +
  ggpubr::theme_pubr() +
  theme(
    legend.position = "right",
    legend.text = element_text(size = 10),
    axis.title = element_blank(), 
    axis.text = element_blank(),  
    axis.ticks = element_blank(),
    axis.line = element_blank(),
    strip.text = element_text(size = 10, face = "bold"),
  ) 

exposures_gen_map

ggsave(
  "exposures_map.pdf",
  plot = exposures_gen_map,
  path = "out/",
  scale = 1.7,
  width = 210,
  height = 160,
  unit = "mm",
  dpi = 350
)

Aggregated ARs

Depression

# effect of violence on dep
# depression
bay_dep_har_agg_adj <-
  readRDS("out/bayesian_models_agg/bay_dep_har_agg_adj.rds")

bay_dep_bul_agg_adj <-
  readRDS("out/bayesian_models_agg/bay_dep_bul_agg_adj.rds")

bay_dep_threats_agg_adj <-
  readRDS("out/bayesian_models_agg/bay_dep_threats_agg_adj.rds")

bay_dep_viol_agg_adj <-
  readRDS("out/bayesian_models_agg/bay_dep_viol_agg_adj.rds")

reg_dep_har <- 
  
  bay_dep_har_agg_adj |> 
  spread_draws(
    b_Intercept, b_work_30_dicYes, r_loc_3[loc_3, term]
    ) |> 
  mutate(
    region_log_No = b_Intercept + r_loc_3,
    region_log_Yes = b_Intercept + r_loc_3 + b_work_30_dicYes
    ) |>
  mutate(
    prob_dep_har_No = plogis(region_log_No),
    prob_dep_har_Yes = plogis(region_log_Yes)
    ) |> 
  group_by(loc_3) |> 
  summarise(
    No_Har_dep = mean(prob_dep_har_No),
    Yes_Har_dep = mean(prob_dep_har_Yes)
    ) |> 
  mutate(loc_3 = str_replace_all(loc_3, "\\.", " ")) |>
  mutate(loc_3 = case_when(
           loc_3 == "М  Київ" ~ "М. Київ",
           TRUE ~ loc_3
         )) |> 
  add_row(tibble_row(loc_3 = "Ар Крим")) |> 
  left_join(ua_reg_conflict |> select(loc_3, loc_en, fips_code),
            by = "loc_3") |> 
  pivot_longer(
    cols = contains("Har_"),
    names_to = "Category",
    values_to = "Probability"
  ) |> 
  mutate(
    Category = case_when(
      str_detect(Category, "No") ~ "No",
      str_detect(Category, "Yes") ~ "Yes"
    ),
    Exposure = "Sexual Harassment",
    Outcome = "Depression"
  ) |> 
  select(-loc_3)



reg_dep_bul <- 
  
  bay_dep_bul_agg_adj |> 
  spread_draws(
    b_Intercept, b_work_33_dicYes, r_loc_3[loc_3, term]
    ) |> 
  mutate(
    region_log_No = b_Intercept + r_loc_3,
    region_log_Yes = b_Intercept + r_loc_3 + b_work_33_dicYes
    ) |>
  mutate(
    prob_dep_bul_No = plogis(region_log_No),
    prob_dep_bul_Yes = plogis(region_log_Yes)
    ) |> 
  group_by(loc_3) |> 
  summarise(
    No_bul_dep = mean(prob_dep_bul_No),
    Yes_bul_dep = mean(prob_dep_bul_Yes)
    ) |> 
  mutate(loc_3 = str_replace_all(loc_3, "\\.", " ")) |> 
  mutate(loc_3 = case_when(
           loc_3 == "М  Київ" ~ "М. Київ",
           TRUE ~ loc_3
         )) |> 
  add_row(tibble_row(loc_3 = "Ар Крим")) |> 
  left_join(ua_reg_conflict |> select(loc_3, loc_en, fips_code),
            by = "loc_3") |> 
  pivot_longer(
    cols = contains("bul_"),
    names_to = "Category",
    values_to = "Probability"
  ) |> 
  mutate(
    Category = case_when(
      str_detect(Category, "No") ~ "No",
      str_detect(Category, "Yes") ~ "Yes"
    ),
    Exposure = "Bullying",
    Outcome = "Depression"
  ) |> 
  select(-loc_3)



reg_dep_threats <- 
  
  bay_dep_threats_agg_adj |> 
  spread_draws(
    b_Intercept, b_work_31_dicYes, r_loc_3[loc_3, term]
    ) |> 
  mutate(
    region_log_No = b_Intercept + r_loc_3,
    region_log_Yes = b_Intercept + r_loc_3 + b_work_31_dicYes
    ) |>
  mutate(
    prob_dep_threats_No = plogis(region_log_No),
    prob_dep_threats_Yes = plogis(region_log_Yes)
    ) |> 
  group_by(loc_3) |> 
  summarise(
    No_threats_dep = mean(prob_dep_threats_No),
    Yes_threats_dep = mean(prob_dep_threats_Yes)
    ) |> 
  mutate(loc_3 = str_replace_all(loc_3, "\\.", " "))|> 
  mutate(loc_3 = case_when(
           loc_3 == "М  Київ" ~ "М. Київ",
           TRUE ~ loc_3
         )) |> 
  add_row(tibble_row(loc_3 = "Ар Крим")) |> 
  left_join(ua_reg_conflict |> select(loc_3, loc_en, fips_code),
            by = "loc_3") |> 
  pivot_longer(
    cols = contains("threats_"),
    names_to = "Category",
    values_to = "Probability"
  ) |> 
  mutate(
    Category = case_when(
      str_detect(Category, "No") ~ "No",
      str_detect(Category, "Yes") ~ "Yes"
    ),
    Exposure = "Violent threats",
    Outcome = "Depression"
  ) |> 
  select(-loc_3)




reg_dep_viol <- 
  
  bay_dep_viol_agg_adj |> 
  spread_draws(
    b_Intercept, b_work_32_dicYes, r_loc_3[loc_3, term]
    ) |> 
  mutate(
    region_log_No = b_Intercept + r_loc_3,
    region_log_Yes = b_Intercept + r_loc_3 + b_work_32_dicYes
    ) |>
  mutate(
    prob_dep_viol_No = plogis(region_log_No),
    prob_dep_viol_Yes = plogis(region_log_Yes)
    ) |> 
  group_by(loc_3) |> 
  summarise(
    No_viol_dep = mean(prob_dep_viol_No),
    Yes_viol_dep = mean(prob_dep_viol_Yes)
    ) |> 
  mutate(loc_3 = str_replace_all(loc_3, "\\.", " "))|> 
  mutate(loc_3 = case_when(
           loc_3 == "М  Київ" ~ "М. Київ",
           TRUE ~ loc_3
         )) |> 
  add_row(tibble_row(loc_3 = "Ар Крим")) |> 
  left_join(ua_reg_conflict |> select(loc_3, loc_en, fips_code),
            by = "loc_3") |> 
  pivot_longer(
    cols = contains("viol_"),
    names_to = "Category",
    values_to = "Probability"
  ) |> 
  mutate(
    Category = case_when(
      str_detect(Category, "No") ~ "No",
      str_detect(Category, "Yes") ~ "Yes"
    ),
    Exposure = "Physical violence",
    Outcome = "Depression"
  ) |> 
  select(-loc_3)




# join all
reg_dep_exp <- 
  
  reg_dep_har |> 
  select(loc_en, fips_code, Outcome, Exposure, Category, Probability) |> 
  bind_rows(reg_dep_bul, reg_dep_threats, reg_dep_viol)


reg_dep_exp
## # A tibble: 208 × 6
##    loc_en                 fips_code Outcome    Exposure     Category Probability
##    <fct>                  <chr>     <chr>      <chr>        <chr>          <dbl>
##  1 Ivano-Frankivsk Oblast UP06      Depression Sexual Hara… No             0.291
##  2 Ivano-Frankivsk Oblast UP06      Depression Sexual Hara… Yes            0.413
##  3 Volyn Oblast           UP24      Depression Sexual Hara… No             0.307
##  4 Volyn Oblast           UP24      Depression Sexual Hara… Yes            0.432
##  5 Vinnytsia Oblast       UP23      Depression Sexual Hara… No             0.316
##  6 Vinnytsia Oblast       UP23      Depression Sexual Hara… Yes            0.442
##  7 Dnipropetrovsk Oblast  UP04      Depression Sexual Hara… No             0.313
##  8 Dnipropetrovsk Oblast  UP04      Depression Sexual Hara… Yes            0.438
##  9 Donetsk Oblast         UP05      Depression Sexual Hara… No             0.306
## 10 Donetsk Oblast         UP05      Depression Sexual Hara… Yes            0.430
## # ℹ 198 more rows
saveRDS(reg_dep_exp, "out/dataframes/region_depression_assoc.rds")
writexl::write_xlsx(reg_dep_exp,
                    "out/dataframes/region_depression_assoc.xlsx")

Anxiety

bay_anx_har_agg_adj <-
  readRDS("out/bayesian_models_agg/bay_anx_har_agg_adj.rds")

bay_anx_bul_agg_adj <-
  readRDS("out/bayesian_models_agg/bay_anx_bul_agg_adj.rds")

bay_anx_threats_agg_adj <-
  readRDS("out/bayesian_models_agg/bay_anx_threats_agg_adj.rds")

bay_anx_viol_agg_adj <-
  readRDS("out/bayesian_models_agg/bay_anx_viol_agg_adj.rds")


# effect of violence on dep
# anxiety
reg_anx_har <- 
  
  bay_anx_har_agg_adj |> 
  spread_draws(
    b_Intercept, b_work_30_dicYes, r_loc_3[loc_3, term]
    ) |> 
  mutate(
    region_log_No = b_Intercept + r_loc_3,
    region_log_Yes = b_Intercept + r_loc_3 + b_work_30_dicYes
    ) |>
  mutate(
    prob_anx_har_No = plogis(region_log_No),
    prob_anx_har_Yes = plogis(region_log_Yes)
    ) |> 
  group_by(loc_3) |> 
  summarise(
    No_Har_anx = mean(prob_anx_har_No),
    Yes_Har_anx = mean(prob_anx_har_Yes)
    ) |> 
  mutate(loc_3 = str_replace_all(loc_3, "\\.", " "))|> 
  mutate(loc_3 = case_when(
           loc_3 == "М  Київ" ~ "М. Київ",
           TRUE ~ loc_3
         )) |> 
  add_row(tibble_row(loc_3 = "Ар Крим")) |> 
  left_join(ua_reg_conflict |> select(loc_3, loc_en, fips_code),
            by = "loc_3") |> 
  pivot_longer(
    cols = contains("Har_"),
    names_to = "Category",
    values_to = "Probability"
  ) |> 
  mutate(
    Category = case_when(
      str_detect(Category, "No") ~ "No",
      str_detect(Category, "Yes") ~ "Yes"
    ),
    Exposure = "Sexual Harassment",
    Outcome = "Anxiety"
  ) |> 
  select(-loc_3)



reg_anx_bul <- 
  
  bay_anx_bul_agg_adj |> 
  spread_draws(
    b_Intercept, b_work_33_dicYes, r_loc_3[loc_3, term]
    ) |> 
  mutate(
    region_log_No = b_Intercept + r_loc_3,
    region_log_Yes = b_Intercept + r_loc_3 + b_work_33_dicYes
    ) |>
  mutate(
    prob_anx_bul_No = plogis(region_log_No),
    prob_anx_bul_Yes = plogis(region_log_Yes)
    ) |> 
  group_by(loc_3) |> 
  summarise(
    No_bul_anx = mean(prob_anx_bul_No),
    Yes_bul_anx = mean(prob_anx_bul_Yes)
    ) |> 
  mutate(loc_3 = str_replace_all(loc_3, "\\.", " "))|> 
  mutate(loc_3 = case_when(
           loc_3 == "М  Київ" ~ "М. Київ",
           TRUE ~ loc_3
         )) |> 
  add_row(tibble_row(loc_3 = "Ар Крим")) |> 
  left_join(ua_reg_conflict |> select(loc_3, loc_en, fips_code),
            by = "loc_3") |> 
  pivot_longer(
    cols = contains("bul_"),
    names_to = "Category",
    values_to = "Probability"
  ) |> 
  mutate(
    Category = case_when(
      str_detect(Category, "No") ~ "No",
      str_detect(Category, "Yes") ~ "Yes"
    ),
    Exposure = "Bullying",
    Outcome = "Anxiety"
  ) |> 
  select(-loc_3)



reg_anx_threats <- 
  
  bay_anx_threats_agg_adj |> 
  spread_draws(
    b_Intercept, b_work_31_dicYes, r_loc_3[loc_3, term]
    ) |> 
  mutate(
    region_log_No = b_Intercept + r_loc_3,
    region_log_Yes = b_Intercept + r_loc_3 + b_work_31_dicYes
    ) |>
  mutate(
    prob_anx_threats_No = plogis(region_log_No),
    prob_anx_threats_Yes = plogis(region_log_Yes)
    ) |> 
  group_by(loc_3) |> 
  summarise(
    No_threats_anx = mean(prob_anx_threats_No),
    Yes_threats_anx = mean(prob_anx_threats_Yes)
    ) |> 
  mutate(loc_3 = str_replace_all(loc_3, "\\.", " "))|> 
  mutate(loc_3 = case_when(
           loc_3 == "М  Київ" ~ "М. Київ",
           TRUE ~ loc_3
         )) |> 
  add_row(tibble_row(loc_3 = "Ар Крим")) |> 
  left_join(ua_reg_conflict |> select(loc_3, loc_en, fips_code),
            by = "loc_3") |> 
  pivot_longer(
    cols = contains("threats_"),
    names_to = "Category",
    values_to = "Probability"
  ) |> 
  mutate(
    Category = case_when(
      str_detect(Category, "No") ~ "No",
      str_detect(Category, "Yes") ~ "Yes"
    ),
    Exposure = "Violent threats",
    Outcome = "Anxiety"
  ) |> 
  select(-loc_3)




reg_anx_viol <- 
  
  bay_anx_viol_agg_adj |> 
  spread_draws(
    b_Intercept, b_work_32_dicYes, r_loc_3[loc_3, term]
    ) |> 
  mutate(
    region_log_No = b_Intercept + r_loc_3,
    region_log_Yes = b_Intercept + r_loc_3 + b_work_32_dicYes
    ) |>
  mutate(
    prob_anx_viol_No = plogis(region_log_No),
    prob_anx_viol_Yes = plogis(region_log_Yes)
    ) |> 
  group_by(loc_3) |> 
  summarise(
    No_viol_anx = mean(prob_anx_viol_No),
    Yes_viol_anx = mean(prob_anx_viol_Yes)
    ) |> 
  mutate(loc_3 = str_replace_all(loc_3, "\\.", " ")) |> 
  mutate(loc_3 = case_when(
           loc_3 == "М  Київ" ~ "М. Київ",
           TRUE ~ loc_3
         )) |> 
  mutate(loc_3 = case_when(
           loc_3 == "М  Київ" ~ "М. Київ",
           TRUE ~ loc_3
         )) |> 
  add_row(tibble_row(loc_3 = "Ар Крим")) |> 
  left_join(ua_reg_conflict |> select(loc_3, loc_en, fips_code),
            by = "loc_3") |> 
  pivot_longer(
    cols = contains("viol_"),
    names_to = "Category",
    values_to = "Probability"
  ) |> 
  mutate(
    Category = case_when(
      str_detect(Category, "No") ~ "No",
      str_detect(Category, "Yes") ~ "Yes"
    ),
    Exposure = "Physical violence",
    Outcome = "Anxiety"
  ) |> 
  select(-loc_3)




# join all
reg_anx_exp <- 
  
  reg_anx_har |> 
  select(loc_en, fips_code, Outcome, Exposure, Category, Probability) |> 
  bind_rows(reg_anx_bul, reg_anx_threats, reg_anx_viol)



reg_anx_exp
## # A tibble: 208 × 6
##    loc_en                 fips_code Outcome Exposure        Category Probability
##    <fct>                  <chr>     <chr>   <chr>           <chr>          <dbl>
##  1 Ivano-Frankivsk Oblast UP06      Anxiety Sexual Harassm… No             0.235
##  2 Ivano-Frankivsk Oblast UP06      Anxiety Sexual Harassm… Yes            0.365
##  3 Volyn Oblast           UP24      Anxiety Sexual Harassm… No             0.229
##  4 Volyn Oblast           UP24      Anxiety Sexual Harassm… Yes            0.357
##  5 Vinnytsia Oblast       UP23      Anxiety Sexual Harassm… No             0.252
##  6 Vinnytsia Oblast       UP23      Anxiety Sexual Harassm… Yes            0.387
##  7 Dnipropetrovsk Oblast  UP04      Anxiety Sexual Harassm… No             0.256
##  8 Dnipropetrovsk Oblast  UP04      Anxiety Sexual Harassm… Yes            0.392
##  9 Donetsk Oblast         UP05      Anxiety Sexual Harassm… No             0.243
## 10 Donetsk Oblast         UP05      Anxiety Sexual Harassm… Yes            0.375
## # ℹ 198 more rows
saveRDS(reg_anx_exp, "out/dataframes/region_anxiety_assoc.rds")
writexl::write_xlsx(reg_anx_exp, "out/dataframes/region_anxiety_assoc.xlsx")

Maps

reg_dep_exp <- readRDS("out/dataframes/region_depression_assoc.rds")
reg_anx_exp <- readRDS("out/dataframes/region_anxiety_assoc.rds")


map_data <- 
  reg_dep_exp |>
  bind_rows(reg_anx_exp)


darkblue = "#0045A8"
aqua = "#38aec5"
cyan = "#00C4D6"

ukraine <- rnaturalearth::ne_states(country = "ukraine", 
                                  returnclass = "sf")

# crimea is included as russia (wrong)
crimea <- 
  rnaturalearth::ne_states(country = "russia",
                                   returnclass = "sf") |> 
  filter(name == "Crimea") |> 
  select(fips, geometry)

map_info_assoc <- 
  ukraine |>
  select(fips, geometry) |>   
  bind_rows(crimea) |> 
  rename(fips_code = fips) |>        
  left_join(map_data, by = "fips_code")


map_info_assoc
## Simple feature collection with 416 features and 6 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: 22.13284 ymin: 44.38105 xmax: 40.15954 ymax: 52.36895
## Geodetic CRS:  WGS 84
## First 10 features:
##    fips_code           loc_en    Outcome          Exposure Category Probability
## 1       UP02 Chernihiv Oblast Depression Sexual Harassment       No   0.3293017
## 2       UP02 Chernihiv Oblast Depression Sexual Harassment      Yes   0.4565794
## 3       UP02 Chernihiv Oblast Depression          Bullying       No   0.2708193
## 4       UP02 Chernihiv Oblast Depression          Bullying      Yes   0.4514300
## 5       UP02 Chernihiv Oblast Depression   Violent threats       No   0.3130299
## 6       UP02 Chernihiv Oblast Depression   Violent threats      Yes   0.4687180
## 7       UP02 Chernihiv Oblast Depression Physical violence       No   0.3530401
## 8       UP02 Chernihiv Oblast Depression Physical violence      Yes   0.4838148
## 9       UP02 Chernihiv Oblast    Anxiety Sexual Harassment       No   0.2625370
## 10      UP02 Chernihiv Oblast    Anxiety Sexual Harassment      Yes   0.3996444
##                          geometry
## 1  MULTIPOLYGON (((31.47485 52...
## 2  MULTIPOLYGON (((31.47485 52...
## 3  MULTIPOLYGON (((31.47485 52...
## 4  MULTIPOLYGON (((31.47485 52...
## 5  MULTIPOLYGON (((31.47485 52...
## 6  MULTIPOLYGON (((31.47485 52...
## 7  MULTIPOLYGON (((31.47485 52...
## 8  MULTIPOLYGON (((31.47485 52...
## 9  MULTIPOLYGON (((31.47485 52...
## 10 MULTIPOLYGON (((31.47485 52...
# depression

dep_assoc_map_grid <-
  
  map_info_assoc |> 
  filter(Outcome == "Depression") |> 
  mutate(Exposure = factor(Exposure, levels = exposure_order)) |>
  arrange(Exposure) |>
  ggplot() +
  geom_sf(aes(fill = Probability),
          color = "white",
          size = 0.2) +
  scale_fill_gradient(low = "#dae6f2",
                      high = darkblue,
                      na.value = "turquoise1",
                      labels = scales::percent,
                      limits = c(0.1, 0.6)) +
  geom_sf_text(
    aes(
      label = ifelse(
        is.na(Probability),
        "ND",
        scales::percent(Probability, accuracy = 1)
        ),
      color = Probability > 0.6
      ),
    size = 2.5,
    check_overlap = FALSE
    ) +
  coord_sf(expand = FALSE) + # removes internal padding between map and box
  scale_color_manual(values = c("black", "white"), guide = "none") +
  facet_grid(rows = vars(Exposure),
             cols = vars(Category)) +
  labs(fill = "Absolute risk") +
  ggpubr::theme_pubr() +
  theme(
    plot.margin = margin(t = 0, r = 0, b = 0, l = 0, unit = "cm"),
    panel.spacing = unit(0.2, "lines"),
    legend.position = "right",
    legend.box.margin = margin(0, 0, 0, 0),
    legend.margin = margin(0, 0, 0, 0),
    legend.text = element_text(size = 10),
    plot.title = element_text(hjust = 0.5),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank(),
    axis.line = element_blank(),
    strip.text = element_text(size = 10, face = "bold")
    ) 


dep_assoc_map_grid

ggsave(
  "assoc_dep_map.pdf",
  plot = dep_assoc_map_grid,
  path = "out/",
  scale = 1.7,
  width = 210,
  height = 160,
  unit = "mm",
  dpi = 350
)

# anxiety


anx_assoc_map_grid <-
  map_info_assoc |> 
  filter(Outcome == "Anxiety") |> 
  mutate(Exposure = factor(Exposure, levels = exposure_order)) |>
  arrange(Exposure) |>
  ggplot() +
  geom_sf(aes(fill = Probability),
          color = "white",
          size = 0.2) +
  scale_fill_gradient(low = "#dae6f2",
                      high = darkblue,
                      na.value = "turquoise1",
                      labels = scales::percent,
                      limits = c(0.1, 0.6)) +
  geom_sf_text(
    aes(
      label = ifelse(
        is.na(Probability),
        "ND",
        scales::percent(Probability, accuracy = 1)
        )
      ),
    size = 2.5,
    check_overlap = FALSE
    ) +
  coord_sf(expand = FALSE) +
  scale_color_manual(values = c("black", "white"), guide = "none") +
  facet_grid(rows = vars(Exposure),
             cols = vars(Category)) +
  labs(
    fill = "Absolute risk") +
  ggpubr::theme_pubr() +
  theme(
    plot.margin = margin(t = 0, r = 0, b = 0, l = 0, unit = "cm"),
    panel.spacing = unit(0.2, "lines"),
    legend.position = "right",
    legend.box.margin = margin(0, 0, 0, 0),
    legend.margin = margin(0, 0, 0, 0),
    legend.text = element_text(size = 10),
    plot.title = element_text(hjust = 0.5),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank(),
    axis.line = element_blank(),
    strip.text = element_text(size = 10, face = "bold")
    ) 
    
anx_assoc_map_grid

ggsave(
  "assoc_anx_map.pdf",
  plot = anx_assoc_map_grid,
  path = "out/",
  scale = 1.7,
  width = 210,
  height = 160,
  unit = "mm",
  dpi = 350
)

Cronbach’s Alpha

phq_items <- 
  ds_ua  |>  
  select(mh_phq_1, mh_phq_2, mh_phq_3, mh_phq_4, mh_phq_5, 
         mh_phq_6, mh_phq_7, mh_phq_8, mh_phq_9)

gad_items <- 
  ds_ua  |>  
  select(mh_gad_1, mh_gad_2, mh_gad_3, mh_gad_4, mh_gad_5, 
         mh_gad_6, mh_gad_7)

# Run

phq_alpha <- psych::alpha(phq_items)


gad_alpha <- psych::alpha(gad_items)


# table

reliability_table <- 
  tibble(
    Scale = c("PHQ-9", "GAD-7"),
    Items = c(9, 7),
    # We extract the Alpha once so we can use it in the calculations below
    Alpha = c(phq_alpha$total$raw_alpha, gad_alpha$total$raw_alpha),
    Lower_CI = Alpha - (1.96 * c(phq_alpha$total$ase, gad_alpha$total$ase)),
    Upper_CI = Alpha + (1.96 * c(phq_alpha$total$ase, gad_alpha$total$ase))
    ) |>
  mutate(across(where(is.numeric), \(x) round(x, 2))) |> 
  gt() |> 
  cols_label(
    Lower_CI = "Lower 95% CI",
    Upper_CI = "Upper 95% CI" 
  )

reliability_table
Scale Items Alpha Lower 95% CI Upper 95% CI
PHQ-9 9 0.89 0.89 0.89
GAD-7 7 0.92 0.92 0.92
gtsave(reliability_table, "out/tables/ukr_cronbach.docx")

Missing values

var_names_orig <- names(ds_ua)

names(ds_ua) <- paste0("Item ", seq_along(ds_ua))

var_names <-
  ds_ua |> 
  select(1:91) |> 
  select(-c("Item 1", 
            "Item 2", 
            "Item 3", 
            "Item 4",
            "Item 5",
            "Item 6",
            "Item 7",
            "Item 8",
            "Item 9",
            "Item 10",
            "Item 11",
            "Item 12",
            "Item 13",
            "Item 20",
            "Item 21",
            "Item 24",
            "Item 26",
            "Item 27",
            "Item 31",
            "Item 62")) |>
  colnames()
  

miss_through_plot <- 
  ds_ua |> 
  select(1:91) |> 
  select(-c("Item 1", 
            "Item 2", 
            "Item 3", 
            "Item 4",
            "Item 5",
            "Item 6",
            "Item 7",
            "Item 8",
            "Item 9",
            "Item 10",
            "Item 11",
            "Item 12",
            "Item 13",
            "Item 20",
            "Item 21",
            "Item 24",
            "Item 26",
            "Item 27",
            "Item 31",
            "Item 62")) |>  
  mutate(
    across(
      everything(),
      ~ as.character(.)
    )
  ) |>
  pivot_longer(
    everything(), 
    names_to = "variable", 
    values_to = "value"
    ) |>  
  mutate(missing = if_else(
    is.na(value), 
    "Missing", 
    "Present")) |> 
  count(variable, missing) |> 
  group_by(variable) |>
  mutate(prop = n / sum(n),
         variable = factor(variable, levels = var_names)) |> 
  filter(missing == "Missing") |>  
  ggplot(aes(x = variable, 
             y = prop)) +
  geom_col(position = "dodge") +
  scale_y_continuous(labels = scales::percent,
                     limits = c(0, 0.25)) +
  scale_fill_grey(start = 0.8, end = 0.2, name = "Data") +
  theme_minimal() +
  labs(x = "Variable", 
       y = "Percent") +
  theme(
    axis.text.x = element_text(angle = 45,
                               hjust = 1,
                               size = 10),
    axis.title.x = element_text(size = 10),
    axis.title.y = element_text(size = 10),
    axis.text.y = element_text(size = 10)
    )


miss_through_plot

ggsave(filename = "missing_vals_through.pdf",
       plot = miss_through_plot,
       path = "out/plots/",
       width = 210,
       height = 170,
       units = "mm",
       dpi = 320,
       scale = 1.5
       )


names(ds_ua) <- var_names_orig


rm(var_names, var_names_orig)